Linux directory and file commands

A list of commonly used linux commands to get you started using the linux file system using the terminal.

List directory
To list the content of a directory use the ls command:
ls <directory name>

Change directory
To change directory use the cd command:
cd <directory name>

Create directory
To create a directory in linux use the mkdir command:

mkdir <directory name>

Remove an empty directory
To remove an empty directory use the rmdir command:

rmdir <directory name>

Remove a not empty directory
To remove a directory which still contains files and directories use the rm command with the -r option (recursively), all files including the directory will be deleted.

rm -r <directory name>

Remove file
To remove a file use the rm command:

rm <file name>

Move a directory
To move a directory use the mv command 

mv <from location\directory name> <to location\new directory name>

Rename a directory or file
To rename a directory also use the mv command.

mv <from location\directory or file name> <to location\new directory or file name>

Find directories and file names
To search for files or directories in the current directory and sub directories use the find command.

find . -name <file name>