Introduction

man

cd

ls

pwd

su

sudo

mkdir

rmdir

rm

mv

cp

history

touch

cat

ping

echo

clear

exit

Thank you!

End

Basic Commands In Linux

What is Linux?

Linux is an Operating System based on the Linux Kernel created by Linus Torvalds. It's most popular "Open Source" Operating System.

Official Website : https://linux.org/

GitHub repo : https://github.com/torvalds/linux

Learn more about git here

What is meant by open source?
Open source means that you can modify the code and redistribute it. Anyone can fix bugs, add features, additional functionalities, etc and contribute to any software that is open source.

Before knowing the commands in Linux, you should realise that memorizing commands is not really necessary, you need not to remember each and every command.

 

Basic Commands

Most of the commands in linux have a help menu, you can access the help menu like this

command --help

man

The man command displays the manual page for the given command. A man page (short for manual page) is a form of documentation that can be referred to know about the program or its arguments

man command

cd

Switch between directories using the cd command

cd /path/Directory/

You can return from a directory to the root directory just by using cd without additional arguments.

cd

ls

The ls command lists the files and folders (content) in a directory

ls

The "ls -a" lists all folders or files which are usually hidden, where "a" is an argument which is short for "--all"

ls -a

pwd

The pwd is short for "present working directory", It prints the current directory you are in

pwd
/root/Desktop

su

The su command is used to switch user

su username

sudo

sudo is used to get "root" user privileges, the root user also called "superuser", is most privileged user on Linux, root user has access to everything on the system. Note that running a process with superuser privilege might be risky!

sudo program

mkdir

The mkdir command is used to make a directory/folder

mkdir folder-name

rmdir

The rmdir command is used to remove a directory/folder.

The "directory must be empty" to use this command or Linux would tell you that you can't do it until you empty the directory using rm command

rmdir folder-name

rm

The rm command is used to remove files in a directory, it can also be used to remove directories using arguments such as -f (--force)

rm file-name

mv

The mv command is used to move or rename files

To move files

mv Directory/file Destination/

To rename files

mv file-name new-file-name

The directories can also be moved and renamed in the same way


cp

The cp command is used to copy files and directories.

cp file Destination/

To copy directories -r argument is used, it is used to copy folders recursively

cp Directory -r Destination/

history

The history command displays a list of the previously used commands

history

We can clear the command history using the -c argument

history -c

touch

It is used to create any file, the file created is empty. The timestamps of a file can be created, modified using touch. Learn more about timestamps here

touch example.py

cat

The cat command prints contents of a file

cat example.txt

ping

The ping command is used to check network connectivity between host and server. We can pass an IP address or a URL in the ping command, to check whether we are able to communicate with the host/server or to find the stats of the connection. Ping stands for "Packet Internet Groper". The time recorded to get a response from the host/server is called "latency" . Low latency with low packet loss indicates faster connection

ping mozilla.org

PING mozilla.org (63.245.208.195) 56(84) bytes of data.
64 bytes from mozilla-org.public.mdc1.mozilla.com (63.245.208.195): icmp_seq=1 ttl=45 time=326 ms
64 bytes from mozilla-org.public.mdc1.mozilla.com (63.245.208.195): icmp_seq=2 ttl=45 time=255 ms
64 bytes from mozilla-org.public.mdc1.mozilla.com (63.245.208.195): icmp_seq=3 ttl=45 time=248 ms
^C
--- mozilla.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 248.005/276.200/325.687/35.105 ms

echo

The echo command is used to print a string or text

echo "Hello! World."
Hello! World.

clear

The clear command clears the terminal screen

clear

exit

The exit command terminates the running program or shell

exit

 

Thank you!

I hope you found this article helpful, please do share it with your friends.

Tags