Beginners guide to Linux commands!!

Abhay R Patel
Code To Express
Published in
3 min readMay 24, 2019

What is Linux??

Linux is an operating system kernel. It is a UNIX clone. Linux is free and open source. Linux has many distributions known as “distros”.RHEL, Ubuntu, Debian are some of them.

What is Linux Shell or Terminal?

Linux shell takes commands from the user gives it to the operating system for processing and gives output.

Basic File commands:

ls displays the list of files and folders.

ls -a displays a list of files including the files starting with a .

ls -t displays files sorted by time, newest first

mkdir DirName used to create a new Directory

cd DirName used to change the current working directory to the specified directory.

cd .. used to Go up one directory

pwd print the current working directory.

touch filename.extension create a file

rm filename Delete a file

rm -r directoryName Delete directory

rm -f filename Force remove a file

head filename Output the first ten lines of a file

tail filename Output the last ten lines of a file

more filename Output the contents of the file

cp firstfilename secondfilename copies the content of first file to the second

System Info

date shows the current date and time

cal shows the month’s calendar

uptime shows the current uptime

whoami displays your username

finger user displays information about the user

uname -a shows kernel information

man command shows the manual for the command

df shows the disk usage

free shows memory and swap usage

whereis app shows possible locations of app

Network

ping host Ping host and output results

whois domain Gives information about the domain

dig domain get DNS information of the domain

dig -x host reverse lookup host

ifconfig configure a network interface

SSH

ssh user@host connect to the host as user

ssh -p port user@host connect to host on port

COMPRESSION

tar is a software for collecting many files into one archive file.The .tar extension is similar to .zip or .7z

tar cf file.tar files Create a tar named file.tar containing files

tar xf file.tar Extract the files from file.tar

VIM EDITOR

vim is the most widely used text editor in Linux

vi filename.extension to create a file and open it in the editor

Press the Insert key and then add text or edit the text in your file.

Press Esc key when done press: wq to save all changes and exit

:q! quit vim without saving changes

:w save the changes

:q to quit when no changes are made. Will fail to quit when some changes are made

INSTALLATION

Installing a package from source

./configure

make

make install

Install a Debian Package

dpkg -i pkg.deb

Install a package(RPM)

rpm -Uvh pkg.rpm

SHORTCUTS

1)ctrl-c stop current command
2)ctrl-z sleep program
3)ctrl-a Go to start of the line
4)ctrl-e Go to end of the line
5)ctrl-u Cut from the start of the line
6)ctrl-r Search history
7)!! Repeat the last command
8)!pqrs Run the last command starting with pqrs
9)!pqrs:p Print last command starting with pqrs
10)^pqr¹²³ Run the previous command replacing pqr with 123

Cheers!!!!

--

--