Linux is an open-source operating system used for
Linux includes many commands that can be performed on the
The most commonly used commands are provided below.
who
who
is a command used to display the users who are currently logged in on the server.
who
grep
grep
is used to search for a given string in a file.
For instance, we would use the following command to search for “user” in the user_file.txt
file:
grep "user" users_file.txt
chmod
chmod
is a command used to change the file permissions.
The permissions can be w
for write, r
for read, or x
for execute.
They can also be represented by their numerical representation, using a combination of the following numbers:
4
: stands for read2
: stands for write1
: stands for execute0
: means no permissionchmod +w file.txt
chmod +r file.txt
chmod +x file.txt
or
chmod 755 file.txt
ssh
ssh
is known as secure shell
. It is a protocol used to securely connect to a remote server.
ssh -l username remotehost.com/IP-address
We can also get the logs using the verbose mode:
ssh -vvv -l username remotehost.com/IP-address
du
and df
du
is used to estimate file space usage.
df
is used to create the disk usage summary. It is especially used to determine how much space a particular directory or file takes.
For example, to find the summary of disk usage for a home
directory with all its sub-directories, we would use:
du /home
To get the disk usage of file/directory with sizes in human-readable format, i.e., in KB, MB, etc:
du -h /home
For the total disk size of a home directory:
du -sh /home
To display information of device name, total blocks, total disk space, used disk space, available disk space, and mount points on a file system:
df
To display information of a particular partition:
df -hT /etc
To find top files which are consuming more space with its subdirectories:
du -s * | sort -nr | head -5
To find the largest file in the current directory:
du -a /home | sort -nr | head -n10
awk '{getline x; print x;}1' file
sed 's/word_to_replace/new_word/g' myfile.txt
grep -io 'unix' file | wc -l
sed 'N; s/\n/,/' file
nl file | sort -nr | cut -f 2-
nl
is a linux command used to number lines.
ls -l | grep "^d" | wc -l
vmstate ==>> virtual memory state
free ==>> free and used physical memory and swap memory
top
top
is a command utility to monitor the Linux system. It provides a summary of the processes currently running on the system.
A zombie process is a process that is already in the terminated state and has completed its execution but that still has an entry in the process table.
When a process is completed in Linux, it is not removed from the system immediately. Instead, the process descriptor stays in memory, and its parent process is notified by the SIGCHILD
signal that the child process has finished execution.
In order to find all zombie processes:
ps aux | grep 'Z'
or
ps -el | grep defunct
In order to kill a zombie process:
kill -s SIGCHILD ppid
Where
ppid
is the parent process ID.
An inode is a data structure that contains metadata about a file when it is changed, accessed, or modified.
The file is assigned a numeric value identifier known as the inode number.
The inode number – also called the index number – stores pieces of information such as:
File type
Size
Permissions
Owner name
Group owners name
Last access/modification time
ACL settings
Link count
Pointer to the memory location where files data is actually stored.
We can check the total number of inodes present on the file system using the disk space command as follows:
df -i /dev/sda1
ls -il abc.txt
1150561 -rw-r - r - 1 mohan mohan 0 Oct 13 03:07 abc.txt