Commands Line Utilities: Difference between revisions
From mylearnings
Jump to navigationJump to search
Created page with "= Process = * Find PID of a known program. <pre> pidof <application name> </pre> * Find all the direct and indirect child processes of a process. <pre> pstree -p <PID> </pre> * List all the files opened by a process with PID. <pre> lsof -p <PID> </pre> * Find details of a file descriptor corresponding to a PID. <pre> lsof -p <PID> -a -d <FD> </pre> ::- -a => Stands for 'AND' Operation. ::- -d => File descriptor for which we need to find details. * Find Parent (PPID)..." |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Format Output = | |||
* Prints only unique line. | |||
<pre> | |||
<command> | uniq | |||
</pre> | |||
* Sorts the lines. | |||
<pre> | |||
<command> | sort | |||
</pre> | |||
* For making a structured table out of text and filter our specific info. | |||
<pre> | |||
sudo docker images | awk -F ' ' 'NR==, NR==12 {print $3, NR-1}' | |||
</pre> | |||
::- sudo docker images => Prints the current docker images in the system. | |||
::- -F ' ' => Field separation is set to space. | |||
::- NR==2 => Start from row 2. | |||
::- NR==12 => End at row 12 | |||
::- {print $3, NR-1} => The command to be executed, Here, print third column based on the field separator and print the line number. | |||
= Process = | = Process = | ||
* Find PID of a known program. | * Find PID of a known program. | ||
Line 24: | Line 45: | ||
* Find Parent (PPID) of a process with PID. | * Find Parent (PPID) of a process with PID. | ||
<pre> | <pre> | ||
</pre> | |||
= File System = | |||
* Check filesystem type. | |||
<pre> | |||
df -T <Path> | |||
</pre> | |||
* See details about a mount. | |||
<pre> | |||
findmnt -T <Path> | |||
</pre> | |||
ps -o ppid= -o comm= -p <PID> | ps -o ppid= -o comm= -p <PID> | ||
= Networking = | |||
= Host Command = | |||
<pre> | |||
pristal@personal-system:~$ host google.com | |||
google.com has address 142.250.196.14 | |||
google.com has IPv6 address 2404:6800:4007:829::200e | |||
google.com mail is handled by 10 smtp.google.com. | |||
pristal@personal-system:~$ | |||
</pre> | |||
* To get the nameservers associated with a domain, | |||
<pre> | |||
pristal@personal-system:~$ host -t ns google.com | |||
google.com name server ns2.google.com. | |||
google.com name server ns1.google.com. | |||
google.com name server ns3.google.com. | |||
google.com name server ns4.google.com. | |||
pristal@personal-system:~$ | |||
</pre> | |||
* To get the mailserver associated with a domain, | |||
<pre> | |||
pristal@personal-system:~$ host -t mx google.com | |||
google.com mail is handled by 10 smtp.google.com. | |||
pristal@personal-system:~$ | |||
</pre> | |||
::- Mail server is ''smtp.google.com'' | |||
::- Here the priority is set to ''10'' | |||
= Nslookup command = | |||
= NetCat Command = | |||
* nc | |||
= Dig Command = | |||
* dig | |||
= Nmap Command = | |||
= Curl Command = | |||
= Wget Command = |
Latest revision as of 13:15, 16 June 2025
Format Output
- Prints only unique line.
<command> | uniq
- Sorts the lines.
<command> | sort
- For making a structured table out of text and filter our specific info.
sudo docker images | awk -F ' ' 'NR==, NR==12 {print $3, NR-1}'
- - sudo docker images => Prints the current docker images in the system.
- - -F ' ' => Field separation is set to space.
- - NR==2 => Start from row 2.
- - NR==12 => End at row 12
- - {print $3, NR-1} => The command to be executed, Here, print third column based on the field separator and print the line number.
Process
- Find PID of a known program.
pidof <application name>
- Find all the direct and indirect child processes of a process.
pstree -p <PID>
- List all the files opened by a process with PID.
lsof -p <PID>
- Find details of a file descriptor corresponding to a PID.
lsof -p <PID> -a -d <FD>
- - -a => Stands for 'AND' Operation.
- - -d => File descriptor for which we need to find details.
- Find Parent (PPID) of a process with PID.
File System
- Check filesystem type.
df -T <Path>
- See details about a mount.
findmnt -T <Path>
ps -o ppid= -o comm= -p <PID>
Networking
Host Command
pristal@personal-system:~$ host google.com google.com has address 142.250.196.14 google.com has IPv6 address 2404:6800:4007:829::200e google.com mail is handled by 10 smtp.google.com. pristal@personal-system:~$
- To get the nameservers associated with a domain,
pristal@personal-system:~$ host -t ns google.com google.com name server ns2.google.com. google.com name server ns1.google.com. google.com name server ns3.google.com. google.com name server ns4.google.com. pristal@personal-system:~$
- To get the mailserver associated with a domain,
pristal@personal-system:~$ host -t mx google.com google.com mail is handled by 10 smtp.google.com. pristal@personal-system:~$
- - Mail server is smtp.google.com
- - Here the priority is set to 10
Nslookup command
NetCat Command
- nc
Dig Command
- dig