Moving And Copying Files In Linux

Article by jonjermey (3,172 pts ) , published Dec 25, 2008

Most Linux distributions come with a graphic file manager, but if you need to move or copy files using the command line this article tells you how.

Graphic file managers

Graphic file managers:

Most Linux distributions now come with a GUI and a graphic file management system. On GNOME based distributions this will usually be Nautilus and KDE systems Konqueror. Both work in a similar way to the Windows File Manager in that files can be moved by dragging them between windows or between different folders in the same window and copied by doing the same thing with the Control key held down. Both file managers come with an Edit menu which contains Copy, Cut and Paste options that can also be used to move or copy files.

Command-line move or copy:

The terminal window can also be used to copy and move files. But for this user you will need to know a little about the Linux file structure. The Linux file system stems from a single root directory represented by a slash character (Windows uses a backslash). Immediately under this there are usually between fifteen and twenty system directories with names like bin, dev and etc. We are mainly concerned with two of these called media and home respectively. The media folder is our gateway to any external devices like CD-ROM's or USB memory sticks and the home folder is where each user’s individual documents and settings are stored. So if Tom, Sue and I all have accounts on the same PC, there will be folders under the home folder called ‘Tom’, ‘Sue’ and ‘Jon’.

Command-line operations

A command line terminal window should be accessible from one of the menus. In Ubuntu for instance it is found by default under Applications / Accessories. This will open up a text entry window with a prompt and flashing cursor. The prompt includes a path string that tells the user whereabouts on the system he or she is located, for instance.

root@jon-ubuntu-laptop:/# – I am located in the root directory

root@jon-ubuntu-laptop:/media# – I am located in the media directory

A tilde character (~) is used to indicate the user’s own subdirectory: e.g.

root@jon-ubuntu-laptop:~# – I am located in my subdirectory under /home i.e. /home/jon

The ‘cd’ (change directory) command is used to move through the system. To move one level upward towards the root directory I enter the command.

cd ..

To move downwards into a subdirectory I enter ‘cd’ followed by the directory name e.g. if I am in the home directory then ‘cd jon’ will take me down from /home into /home/jon. The ‘cd ~’ (tilde) command will always take me to my home directory and ‘cd /’ will take me straight to the root directory.

cd jon - down to jon

cd .. - up one level

cd / - up to root directory

cd ~ - to home directory