Basic Linux Commands

Basic Linux Commands

This article deals with command line interface(CLI) rather than graphical user interface(GUI).If you want to learn the basic commands to operate on your terminal then , you should definately go through this article and learn these commands.

First , you should understand , what is the meaning of a command: A command is a software program that when executed on the CLI performs an action on the computer. When you type in a command, a process is run by the operating system that can read input, manipulate data and produce output.

List of commands:

Most of the commands follows a generic syntax

command [options…] [arguments…]

The 'ls' Commands:

to display list of files present in current directory

ls

common options:

'-l:To display more information about each of the files listed:

ls -l

'-a' : This option will list hidden files too.

ls -a

- To print results in reverse order alphabetical order use:

ls -r

- To sort files by timestamp:

ls -lt

- To sort files by size use:

ls -l -S

The 'man' Command:

man command is used to display the user manual of any command that we can run on the terminal.

man ls

you can exit the user manual by typing q and hit enter.

The 'cd' Commands:

To change from one directory/folder to another use:

cd [directory name]

To move to home directory use:

cd ~

To toggle between current directory and previous directory use:

cd -

To move to previous directory use:

cd ..

The 'mkdir' Command:

To create a directory use:

mkdir dir1

The 'mv' Command:

To move or To rename a file use :

mv file1.txt file2.txt

The 'cp' Command:

To copy a directory named source_directory and all its contents into another directory named destination_directory, you would use:

cp -r source_directory destination_directory

The 'pwd' Command:

To print working directory use:

pwd

The 'rm' Command:

To remove a file, you would simply type rm followed by the name of the file you want to delete:

rm filename.txt

To remove a directory and all its contents recursively, you would use the '-r' option:

rm -r directory_name

The 'touch' Command:

To create an empty file use:

touch filename

The 'cat' Command:

To display the content of a file use:

cat filename

The 'chmod' Command:

This command is used to change the permissions (read, write, execute) of files and directories :

To give read, write, and execute permissions to the owner of a file (user), read and execute permissions to the group (group), and read-only permissions to others use:

chmod u+rwx,g+rx,o+r filename

To recursively change the permissions of a directory and its contents use:

chmod -R 755 directory_name

There are a lot more commands which you can learn and practice .