Search

10 basic commands that every regular Linux users need to know Part 2

post-title

In the previous article, we have discussed basic commands that almost every Linux user need in the regular work. These commands are common for all Linux distribution.

In this article, we will discuss about more commands that are not essentially required but it is good practice to use it. These commands may be hard for new Linux user but it is essential for daily Linux user. Here are the few commands that are helpful for regular day to day work for Linux users.

chmod

The chmod command change the file or folder permission to read, write and execute. These permissiona are for owner user, group of users and for others.

There are two ways you can assign or check permissions for file or folder. In a numeric way you can assign permission:

r (read) = 4
w (write) = 2
x (execute) = 1
no permissions = 0

These permission number in 3 numeric digit. Suppose a file has permission of 755, then below are this permisssion.

Owner has read, write and execute rwx = 4+2+1=7
Group has read and execute permission r-x = 4+0+1=5
Others has read and execute permission r-x = 4+0+1=5

To change the file or permission, run the commands:

chmod 777 /path/to/dir

To recursively set read, write, and execute permissions, use -R option.

chmod -R 755 /path/to/file

df

You can easily check disk space with df command. For human readable format, use -h option.

df -h

free

free command will return total physical memory and swap space. You can better manage about swap space. -h option will allow to view in human readable format.

free -h

grep

grep command is used to search for string or search for pattern in the file.

grep 'string' file.txt

To search with case insensitive, use -i option.

grep -i 'String' file.txt

You can also search from multiple files.

grep -i 'String' file.txt file2.txt file3.txt

Also search pattern can be used.

grep '^string' file.txt

cat

cat command let you to view file content.

cat /path/to/file

kill

Sometimes you want to close the program, which you can not close from GUI. You can stop program by process id.

kill process-id

To forcefully close the program, use -9 option.

kill -9 pid

To view the process id of program, run ps command.

ps aux

To close all subprocess of the program. you can simply use killall command.

killall pid

shutdown

shutdown command used to halt and shutdown the computer. You can simply set time to shutdown computer.

shutdown 10:30

or after minutes.

shutdown +30

To stop shutdown use -c option.

shutdown -c

Reboot the machine with -r option.

shutdown -r

uname

uname comman will print the system option.

print all information with -a option.

uname -a

Or with specific information with below options.

print the kernel name

uname -s

print the network node hostname

uname -n

print the kernel release

uname -r

print the kernel version

uname -v

print the machine hardware name

uname -m

print the processor type (non-portable)

uname -p

print the operating system

uname -o

w

w command  displays information about the users currently on the machine, and their processes. The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

whoami

whoami command print the current logged user name.