Very Basic Commands for Ubuntu

Here we give a list of Basic command that can be used on Ubuntu(or linux) OS. All these command will work in “Terminal”.

man command

Use this command to get help pages for any command.

man <command-name>

Use “q” to quit the help page (or the man command).

If you want to get options that can be used with a command, man is the command that will help you on that.

pwd command

Use this command to know the present working directory. If you open “Accessories->Terminal”, the terminal opens in /home/<user-name>.

pwd

The above command for a user named “jaggib” will give:

/home/jaggib

Path of directory

A directory path can be:

  • absolute
  • relative

absolute
The path with reference to root directory is called absolute.

/home/jsbisht

This is the path of user directory from root directory.

relative
The path with reference to current directory is called relative.

/Downloads/my-files

You can also target the sibling directories of the current directory.

../Documents/my-work

Same can be approached to target even higher parent folders.

../../Directory

Shortcut to home directories is available.

~

ls command

Use this command to get a list of files and directories that are in the present working directory.

ls

Now you can change the way the data will be displayed, using the options:

ls [option]

You can also use “ls” to get a view of file attributes for each file or directory by using:

ls -l

You can use “ls” to view hidden (or system) directories and files also using:

ls -la

touch command

Use this command to create a file in the present working directory. It can also be used to Update  the  access  and modification time on a file.

touch <file-name>

The following example will create a new file file.txt.

touch file.txt

mkdir command

command to make a directory in the present working directory (i.e. current directory).

mkdir <directory-name>

The following example would create a new directory my-work.

mkdir my-work

cd command

Use this command to change the directory i.e. to change from current working directory to some other directory.

cd <directory-name>

OR

cd <directory-path>

where, directory path can be absolute or relative.

cp command

Use this command to copy a file(s) or directory(s).

cp <file-to-be-copied> <copied-file-name>

rm command

Use this command to remove a file(s) or directory(s).

rm <file-name>

To remove a file forcefully (without prompt) when in interactive mode:

rm -f <file-name>

To remove a directory:

rm -r <directory-name>

To remove directory and its subdirectories and files recursively:

rm -rf <directory-name>

mv command

Use this command to move files from one directory to other (also used for renaming).

mv <source-name> <destination-name>

If destination specified doesnt exist, it will create a new file. So, it functions as cp command in that case.

If destination is a directory name, the source is a file then it will be copied into the directory name specified.

mv file.txt \Documents

If both are files, the source file would be removed and destination file would be created with the same content as source file. Also, note that if there exist a file already with the specified destination file name, it will be replaced too.

If the source folder is a directory with subdirectories and files, you can copy whole content recursively using -R argument.

mv -R /source_dir /destination_dir

sudo command

Use this command to run a command as  administrator (or the user having privileges to execute that command).

sudo <command-name>

Lets say you want to open file manager as root, you can do it using sudo:

sudo nautilus