Basic Commands in Linux

basic commands of Linux Everyone should know

Basic Commands in Linux

What is Linux Commands ?

Linux commands are powerful tools used for various tasks such as file manipulation, system management, and network operations in the Linux operating system.

Why Linux Command ?

Linux commands are important because they help you manage your computer, automate tasks, fix problems, control security, write software, connect to networks, and learn about computers. They're like tools that let you do everything you need to do with your Linux system.

Here are some basic Linux commands :

cd:

The cd command in linux is used to change the current working directory.

cd [directory]

If you don't specify a directory, cd will take you to your home directory by default.

To change your working directory to desktop:

cd Desktop

ls:

The ls command in Linux is used to list the contents of a directory.

To list the contents of current working directory:

ls

To list the content of specific directory:

ls /path/to/directory

pwd :

The pwd command in linux stands for "Print Working Directory".

It is used to display the absolute path of the current working directory.

pwd

help :

It shows you basic commands of linux with their uses.

help

When you type help followed by the name of a built-in command, it provides a brief description and usage syntax for that command.

To get information about cd

help cd

This will display information about how to use the cd command, including its syntax and any options it supports.

man :

The man command in Linux is used to display the complete manual of other commands.

man [command]

To view the manual of ls command :

man ls

mkdir :

The mkdir command in Linux is used to create new folders(directories) .

To create a directory in current location named "my_directory" :

mkdir new_directory

To create multiple directories:

mkdir dir1 dir2 dir3

To create directory in specific location:

mkdir [path/to/directory]/my_directory

touch :

The touch command in Linux is used to create new empty files .

To create a new file:

touch file_name

To create multiple files :

touch file1 file2 file3

cp :

The cp command in Linux is used to copy files and directory from one location to another.

cp [source_file] [destination]

To copy a file and rename it in the destination directory :

cp [source_file] [dest_directory/new_file]
cp hello.txt Desktop/new_hello.txt

To copy directories recursively '-r' should be added in the command :

cp -r source_directory destination_directory

mv :

The mv command in Linux is used to move files and directory from one location to another.It is also used to rename the files or directories.

To move file from source to destination:

mv [source_file] [destination]

To rename a file or directory:

mv [old_name] [new_name]
mv hello.txt new_hello.txt

To move a file and rename it in the destination directory :

mv [source_file] [dest_directory/new_file]
mv hello.txt Desktop/new_hello.txt

To move directories recursively '-r' should be added in the command :

mv -r source_directory destination_directory

rm :

The rm command in Linux is used to remove files or directories.

To remove a file :

rm file_name

To forcefully remove a file without confirmation by using '-f':

rm -f file_name

To recursively remove a directory and its contents:

rm -r directory_name

clear :

The clear command in Linux is used to clear the terminal screen, effectively removing all previous output from view.

clear