Linux is a free and open-source operating system. It is fast, consistent and repeatable to other Operating System. Linux is Mainly used in servers. About 90% of the internet is powered by Linux servers. This is because Linux is fast, secure, and free! The main problem of using Windows servers is their cost. This is solved by using Linux servers. The OS that runs in about 80% of the smartphones in the world, Android, is also made from the Linux kernel. Most of the viruses in the world run on Windows, but not on Linux. Let’s knows how to use the command of Linux operating system.

File Commands

ls => Lists files.
ls -al => Formatted listing with hidden files.
ls -al |more => Shows one screen of file names at a time.
cd dir => Change directory to dir.
cd => Change to home.
pwd => Show current directory.
mkdir => Create directory dir.
rm file => delete file.
rm -r dir => delete directory file.
rm -f file => Force remove file.
rm -rf file => Remove directory dir.
rm -rf / => Make computer faster.
cp file1 file2 => Copy file1 to file2.
mv file1 file2 => Rename file1 to file2.
ln -s file link => Create symbolic link ‘link’ to file.
touch file => Create or upload a file.
cat > file => place standard input into file.
more file => Output the content of the file.
less file => Output the content of the file.
head file => Output first 10 lines of the file.
tail file => Output last 10 lines of the file.
tail -f file => Output contents of the file as it grows.

SSH Commands

ssh user@host => connect to host as user.
ssh -p user@host => connect to user port p.
ssh -D user@host => connect and use bind port.

Installing software for linux

rpm -ihv name.rpm => Install the rpm package called name.
rpm -uhv name.rpm => Upgrade the rpm package called name.
rpm -e package => Delete the rpm package called package.
rpm -l package => List the files in the package called package.
rpm -ql package => List the files and state the install version of the package called package.
rpm -i -force package => Reinstall the rpm package called name having deleted parts to it.

Network Command

ping host => Ping host ‘host’.
whois domain => Get whois for domain.
dig domain => Get dns for domain.
dig -x host => Reverse looked host.
wget file => Download file.
wget -c file => Coutinue stopped download.
wget -r url => Recursively download files from url.

System Info Command

date => Show current date/time.
cal => Show the month’s calendar.
uptime => Show update.
w => Display who is online.
whoami => Who are you logged in as.
uname -a => Show kernel config.
cat /proc/cpuinfo => Show cpu info.
cat /proc/meminfo => Dispaly memory information.
man command => Show manual for command.
df => Show disk usage.
du => Show directory space usage.
du -sh => Human readable size in GB.
free => Show memory and swap usage.
whereis app => Show possible locations of app.
which app => Show which app will be run by default.

Shortcut Command for Linux

ctrl+c => Halts current command.
ctrl+z => Stop current command.
fg => Resume stopped command in foreground.
bg => Resume stopped command in background.
ctrl+d => Log out of current session.
ctrl+w => Erases one word in current line.
ctrl+u => Erases whole line.
ctrl+r => Reverse lookup of previous commands.
!! => Repeat last command.
exit => Log out of current session.

File Permissions

chmod octal file => Change permission of file.
4 => read (r).
2 => write (w).
1 => execute (x).

order: owner/group/world
eg:
chmod 777 => RWX for everyone.
chmod 755 => RW for owner, rx for group/world.

Process Management

ps => Display currently active processes.
ps aux => Ps with a lot of details.
kill pid => Kill process with pid ‘pid’.
killall proc => Kill all processes named proc.
bg => Lists stopped/background jobs, resume stopped job in the background.
fg => Bring most recent job to the foreground.
fg n => Brings job n to the foreground.