Pages

Wednesday, 13 March 2013

change directory, move, copy, remove and symbolic link

Here some command that every linux user must know:

Change directory (cd)

To go in the directory dest:
cd dest


Go in the up one directory:
cd ..

Move (mv)

To move the file source to directory dest:
mv source dest

If we want move all .png image for example to dest:
mv *.png dest

We can move also a directory or all the files in a directory if we use the * symbol. It can be used as well to renominate a file.


Copy (cp)

Basically the same syntax as mv command:

cp source directory


Remove (rm)

To remove a file:
rm file


If we want remove a whole directory we must use the option -r (recursive):
rm -r directory


Symbolic link (ln -s)

This command is very useful, it make a "symbolic link" of a file or a directory wherever we want, to avoid multiple identical file.
To create a link of the file source in the directory dest:
ln -s source dest


To have a link of source with another name, for example link in the directory dest:
ln -s source dest/link


Here some real example of use:

Renominate .bashrc as .bashrc.old
mv .bashrc .bashrc.old

Copy the renominate file as .bashrc (I know that it doesn't have any sense, we can copy it from the beginning):
cp bashrc.old .bashrc


Remove .gnome/apps
rm -r ~/.gnome/apps

Create a symbolic link of /usr/share/icons to the home directory with the name ico:
ln -s /usr/share/icons ~/ico




No comments:

Post a Comment