Friday, July 5, 2013

Copy/Make/Move/Remove/Create Links-1 in Ubuntu/Linux[Learn ubuntu/Linux with me -Day 2]



Click on the images for a better enlarged view.


Looking at the title of post one may say ...Hey Ajay you are an idiot...Copy/paste this is the first task any user can do with a mouse click or simple drag and drop can do that. well I'll say by th end you'll understand.The commands which you are going to learn in this post will be used widely so just fire up terminal create dummy folders on your Desktop with some text files in them.

Command Description
mkdir directory... Why the heck did you put three dots?
Because you can repeat that..
What??
Here's the example
mkdir dir1 dir2 dir3 dir4
This will create the four directories.
cp item1 item2 item1 and item2 can be a file/directory
cp item1 item2 item3 directory
This will copy all items to the directory.
mv item1 item2 Moving and Renaming is done using this.
rm item Remove files
ln file link
ln -s item link
creates hard link
Creates symbolic link


 This is a bit complicated tutorial you need to do a lot of typing
mkdir:
The syntax is simple and self explanatory

cp:

copies files and directories

cp <somedir/somefile> .

did u see a dot at the end..?? copy a file from the given location to the current working directory.Check the image
dot/period is equivalent to current directory

you can do much more with copy


mv:

Renaming files and Moving the directories.

mv somefile somefile1

The above command does this ==> somefile is renamed to somefile1

mv somefile1 somedir1

this will move somefile1 to somedir1

Example :

1.cd Desktop ==>this will take you to Desktop
2.mkdir facebook ==>This will create facebook directory on your Desktop
3.cd facebook ==>This will take you inside facebook directory
4.mkdir profile friends job education relationship ==>will create 5 directories inside facebook directory
5.mv education friends job relationship profile ==>education friends job relationship directories are moved to profile directory
6.ls -l ==>Displays files/dirs in longer format[-l for longer].Now you can see only one directory inside facebook that's profile
7.cd profile ==>change your directory to profile.
8.ls -l displays files and dirs
9.cp -v /etc/passwd .
what the heck is this??
general syntax for copy ==> cp <from location of file> <to location>
cp is for copy ...v for verbose...
there is a password file @  /etc/passwd ==>from location
to location: . (period/dot stands for current location),So what's current location?it's facebook directory.
10.ls -l gives  profile dir and passwd file

The rest you can play around..
cp -i
i??i means interactive like if the to location has already that file cp -i will ask for your permisssion should it overwrite or not?if you type y it will overwrote else if you type n it will not overwrite the file.
cp -v will not tell you anything if a duplicate file exists,it just overwrites the file.


click the image for a better view and try these commands.


 This is too much for one post I'll post the rest in next post.Links are bit tough to understand...Play around with these.More you type more you learn.

Learn python for fun.The popular blog with questions and answers to the python.Solutions to facebookhackercup,codejam,codechef.The fun way to learn python with me.Building some cool apps.

No comments:

Post a Comment