Although most of the Linux operating systems are now with easy to user and interactive graphical user interface, the beauty of Linux distros is still with a command-line shell.
It is a most important tool that lets us quickly install and operate various applications without going through multiple windows. Moreover, there are many Linux and server applications that still only works via command console, thus that’s why one should at least familiar with command Shell commands
The Linux commands given in the table of this article are some of that we require in our daily usage. Also, if you are just a beginner to Linux, then you can use the TAB key that helps you in completing commands or showing suggestions.
Just type in the first few characters, then hit the tab key and the rest will be added automatically. This works with file, directory, and program names. The tab key is also very helpful when you want to find out whether a program is already installed on the system.
Common Linux Commands to start with command line terminal
Syntax | Explanation | Example |
[Command] & | You can continue to use the console | firefox & |
[Command] && [command] | Commands are executed one after the other | firefox && shutdown -h now |
man [program] | Displays help for a program | man firefox |
ctrl + C | Cancels the current process in the shell | ctrl + C |
For Directories & files | ||
cd [directory] | Changes to the directory | cd / tmp |
cd .. | Changes one directory higher | – |
cd / | Changes to the root directory | cd / |
cd – | Changes to the previous directory | cd – |
cp [file] [directory] | Copies file to directory | cp 123.txt / tmp |
mv | Moves a file | mv 123.txt / tmp |
mv [file1] [file2] | renames file [FILE1] to [FILE2] | mv 123.txt 456.txt |
rm | Deletes a file | rm /tmp/123.txt; rm / tmp / * |
rm -rf | delete everything below the directory | rm -rf / tmp / |
mkdir | Creates a directory | mkdir / home / test |
rmdir | Deletes a directory | rmdir / home / test |
ls | Displays folder contents | ls / home / test |
ls -l | Detailed listing | ls -l / home / test |
ls -la | all files in the directory in detail | ls -la / home / test |
alias ls = ‘ls –color’ | Sets colored view | alias ls = ‘ls –color’ |
pwd | Displays the current directory | pwd |
cat [file] | Shows the contents of a file | cat 123.txt |
more [file] | Displays the contents of a file page by page | more 123.txt |
touch [file] | Creates an empty file | touch 123.txt |
whereis [Prog] | Looks for program | whereis Firefox |
find. | grep [FILE] | searches for a file in the directory | find. | grep 123.txt |
grep [KEY] [FILE] | Searches for a term in a file | grep house 123.txt |
locate [FILE] | Searches for file in the database | locate 123.txt |
updatedb | Updates the database | updatedb |
which | Shows where a program is located | which firefox |
For System tasks | ||
arch | Processor family | arch |
cat / proc / filesystems | Supported file systems | cat / proc / filesystems |
cat / proc / cpuinfo | Information about the CPU | cat / proc / cpuinfo |
cat / proc / filesystems | All supported file systems | cat / proc / filesystems |
cat / proc / pci | Information about the PCI cards | cat / proc / pci |
dmesg | grep hd | Info about all drives | dmesg | grep hd |
date | date and time | date |
dmesg | Kernel logger: Shows kernel activity | dmesg |
free | Shows usage of the main memory | free |
glxgears | Small graphics test on the performance of the VGA | glxgears |
glxinfo | Information about OpenGL and graphics card | glxinfo |
kill [PID] | Kills process with a specific ID | kill 1067 |
killall [Prog] | Kills process with process name | killall Firefox |
lspci | Information about PCI components | lspci |
shutdown -h now | Shuts down the computer | shutdown -h now |
shutdown -r now | Restarts the computer | shutdown -r now |
Top | Shows programs and CPU usage | Top |
uptime | How long has the PC been in operation? | uptime |
X version | Displays version of Xfree | X version |
For Hard disk | ||
df | Show storage space | df -h |
fdisk | Partition hard drive | fdisk / dev / hda |
mkfs.ext2 | Format HDD with ext2 | mkfs.ext2 / dev / hda1 |
mkfs.ext3 | Format HDD with ext3 | mkfs.ext3 / dev / hda1 |
mkreiserfs | Format HDD with reiserfs | mkreiserfs / dev / hda1 |
sync | save buffered data on HDD | sync |
Mount | ||
mount | Mounts volumes in the system | mount / dev / hda1 / mnt / win |
mount -t [filesystem] | Mounts with the given file system | mount -t ntfs / mnt / win_xp |
mount -a | Mounts all volumes from / etc / fstab | mount -a |
mount -r | The data carrier can only be read | mount -r / mnt / win |
mount -w | Data carrier can be read and written | mount -w / mnt / win |
mount -m | Mounts without an entry in / etc / mtab | mount -n / mnt / win |
user | ||
id | Displays username and group | id |
wer bin ich | Shows the currently logged in user | wer bin ich |
who | Who is logged in? | who |
groupadd [group] | Creates a new group | groupadd admins |
groupdel [group] | Deletes a new group | groupdel admins |
useradd -m [USER] | Creates user and home directory | useradd -m boss |
userdel -r [USER] | Deletes user and home directory. | useradd -m boss |
passwd [USER] | Changes the user’s password | passwd boss |
see below | You are now working as root on the console | see below |
su [USER] | You are now working as [USER] on the console | su boss |
Network related | ||
ifconfig | Displays network information | ifconfig |
iwconfig | Shows information about the WLAN | iwconfig |
ping [computer] | Tests connection to a computer | ping 192.168.0.1 |
Kernel and modules | ||
lsmod | Shows loaded modules | lsmod |
make menuconfig | Setting up the kernel | cd / usr / src / linux; make menuconfig |
modprobe [module] | Loads a module | modprobe printer |
uname -a | Shows the kernel version | uname -a |
Others | ||
ps aux | Shows all running processes and services | ps aux |
rc update show | Shows the services that are loaded at startup | rc update show |
Submitted by a Guest Author- Sundar Prakash