Directory and file commands (in Linux)

Note: Some of these commands must be entered as root (administrator).

~
The tilde Web icon is used to move to the users home directory, while in any other directory.
cd
cd can be used to change the directory you are in.
To go to the mnt directory, type:
cd /mnt
To move up a directory, such as going from /home/user to /home, type:
cd ..
ls
ls is used to list the directory contents.
To list the contents of some-directory with minimal information, type:
ls /some-directory
To list the contents of some-directory with detailed information, type:
ls -laF /some-directory
du
du can be used to view disk usage, e.g. list directories and sizes.
To view disk space usage of some-directory, type:
du -h /some-directory
df
df can be used to display the amount of available disk space.
To display the available free space of all filesytems, type:
df -h
cat
cat can be used to print (via the terminal) the contents of a file.
To display the contents of fstab, type:
cat /etc/fstab
mkdir
mkdir can be used to create a directory.
To make a directory called some-directory, type:
mkdir some-directory
cp
cp is used to copy a file.
To copy some-file as some-file-backup, type:
cp some-file some-file-backup
To copy some-directory and all it's contents to another-directory, type:
cp -r /some-directory /another-directory
mv
mv is used to move or rename a file or directory.
To move some-file from directory to another-directory, type:
mv /directory/some-file /another-directory/some-file
rm
rm is used to remove (delete) a file.
To remove some-file, type:
rm some-file
To remove some-directory, and all it's contents, type:
rm -r some-directory
rmdir
rmdir is used to remove (delete) an empty directory.
To remove some-directory, type:
rmdir some-directory
touch
touch is used to create a file (if file already exists, the timestamp is updated).
To create the file some-file, type:
touch some-file

Go back to the How-to Guides main page.

Search

Starter website

Offering small businesses and individual users the opportunity to have their own website on the internet, our 'starter websites' are available for only £150.

new site offer

To find out more and to see an example of the type of site offered, view our example starter website page.