reworking content
All checks were successful
learn org at code.softwareshinobi.com/linux.softwareshinobi.com/pipeline/head This commit looks good

This commit is contained in:
2025-06-19 10:03:08 -04:00
parent 611d0816cc
commit 7d9171c854
192 changed files with 2234 additions and 2362 deletions

View File

@@ -0,0 +1,105 @@
# The `df` command
The `df` command in Linux/Unix is used to show the disk usage & information.
`df` is an abbreviation for "disk free".
`df` displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.
### Syntax
```
df [OPTION]... [FILE]...
```
### Options
|**Short Flag**|**Long Flag**|**Description**|
|:--|:--|:--|
|`-a`|`--all`|Include pseudo, duplicate, inaccessible file systems.|
|`-B`|`--block-size=SIZE`|Scale sizes by SIZE before printing them; e.g., `-BM` prints sizes in units of 1,048,576 bytes; see SIZE format below.|
|`-h`|`--human-readable`|Print sizes in powers of 1024 (e.g., 1023M).|
|`-H`|`--si`|Print sizes in powers of 1000 (e.g., 1.1G).|
|`-i`|`--inodes`|List inode information instead of block usage.|
|`-k`|<center>-</center>|Like `--block-size=1K`.|
|`-l`|`--local`|Limit listing to local file systems.|
|<center>-</center>|`--no-sync`|Do not invoke `sync` before getting usage info (default).|
|<center>-</center>|`--output[=FIELD_LIST]`|Use the output format defined by `FIELD_LIST`, or print all fields if FIELD_LIST is omitted.|
|`-P`|`--portability`|Use the `POSIX` output format|
|<center>-</center>|`--sync`|Invoke sync before getting usage info.|
|<center>-</center>|`--total`|Elide all entries insignificant to available space, and produce a grand total.|
|`-t`|`--type=TYPE`|Limit listing to file systems of type `TYPE`.|
|`-T`|`--print-type`|Print file system type.|
|`-x`|`--exclude-type=TYPE`|Limit listing to file systems not of type `TYPE`.|
|`-v`|<center>-</center>|Ignored; included for compatibility reasons.|
|<center>-</center>|`--help`|Display help message and exit.|
|<center>-</center>|`--version`|Output version information and exit.|
### Examples:
1. Show available disk space
**Action:**
--- Output the available disk space and where the directory is mounted
**Details:**
--- Outputted values are not human-readable (are in bytes)
**Command:**
```
df
```
2. Show available disk space in human-readable form
**Action:**
--- Output the available disk space and where the directory is mounted
**Details:**
--- Outputted values ARE human-readable (are in GBs/MBs)
**Command:**
```
df -h
```
3. Show available disk space for the specific file system
**Action:**
--- Output the available disk space and where the directory is mounted
**Details:**
--- Outputted values are only for the selected file system
**Command:**
```
df -hT file_system_name
```
4. Show available inodes
**Action:**
--- Output the available inodes for all file systems
**Details:**
--- Outputted values are for inodes and not available space
**Command:**
```
df -i
```
5. Show file system type
**Action:**
--- Output the file system types
**Details:**
--- Outputted values are for all file systems
**Command:**
```
df -T
```
6. Exclude file system type from the output
**Action:**
--- Output the information while excluding the chosen file system type
**Details:**
--- Outputted values are for all file systems EXCEPT the chosen file system type
**Command:**
```
df -x file_system_type
```

View File

@@ -0,0 +1,92 @@
# The `top/htop` command
`top` is the default command-line utility that comes pre-installed on Linux distributions and Unix-like operating systems. It is used for displaying information about the system and its top CPU-consuming processes as well as RAM usage.
`htop` is interactive process-viewer and process-manager for Linux and Unix-like operating system based on ncurses. If you take top and put it on steroids, you get htop.
## Comparison between top and htop:
|**Feature** |**top** |**htop** |
|:---|:---|:---|
|Type|Interactive system-monitor, process-viewer and process-manager|Interactive system-monitor, process-viewer and process-manager|
|Operating System|Linux distributions, macOS |Linux distributions, macOS |
|Installation|Built-in and is always there. Also has more adoption due to this fact.|Doesn't come preinstalled on most Linux distros. Manual installation is needed|
|User Interface|Basic text only|Colorful and nicer text-graphics interface|
|Scrolling Support|No|Yes, supports horizontal and vertical scrolling|
|Mouse Support|No|Yes|
|Process utilization|Displays processes but not in tree format|Yes, including user and kernel threads|
|Scrolling Support|No|Yes, supports horizontal and vertical scrolling|
|Mouse Support|No|Yes|
|Process utilization|Displays processes but not in tree format|Yes, including user and kernel threads|
|Network Utilization|No|No|
|Disk Utilization|No|No|
|Comments|Has a learning curve for some advanced options like searching, sending messages to processes, etc. It is good to have some knowledge of top because it is the default process viewer on many systems.|Easier to use and supports vi like searching with `/`. Sending messages to processes (kill, renice) is easier and doesn't require typing in the process number like top.|
## Examples:
### `top`
1. To display dynamic real-time information about running processes:
```
top
```
2. Sorting processes by internal memory size (default order - process ID):
```
top -o mem
```
3. Sorting processes first by CPU, then by running time:
```
top -o cpu -O time
```
4. Display only processes owned by given user:
```
top -user {user_name}
```
### `htop`
1. Display dynamic real-time information about running processes. An enhanced version of `top`.
```
htop
```
2. displaying processes owned by a specific user:
```
htop --user {user_name}
```
3. Sort processes by a specified `sort_item` (use `htop --sort help` for available options):
```
htop --sort {sort_item}
```
## Syntax:
```
top [OPTIONS]
```
```
htop [OPTIONS]
```
## Additional Flags and their Functionalities:
|**Short Flag** |**Long Flag** |**Description** |
|:---|:---|:---|
|`-a`|<center>-</center>|Sort by memory usage.|
|`-b`|<center>-</center>|Batch mode operation. Starts top in 'Batch mode', which could be useful for sending output from top to other programs or to a file. In this mode, top will not accept input and runs until the iterations limit you've set with the '-n' command-line option or until killed.|
|`-h`|<center>-</center>|`top --user {user_name}` Only display processes owned by user.|
|`-U`|<center>-user</center>|Help.|
|`-u`|<center>-</center>|This is an alias equivalent to: -o cpu -O time.|

View File

@@ -0,0 +1,118 @@
# The ``lsblk`` command
## Summary
The ``lsblk`` command displays the block and loop devices on the system. It is especially useful when you want to format disks, write filesystems, check the filesystem and know the mount point of a device.
## Examples
1. Basic usage is fairly simple - just execute 'lsblk' sans any option.
```
lsblk
```
2. Make lsblk display empty devices as well
```
lsblk -a
```
3. Make lsblk print size info in bytes
```
lsblk -b
```
4. Make lsblk print zone model for each device
```
lsblk -z
```
5. Make lsblk skip entries for slaves
```
lsblk -d
```
6. Make lsblk use ascii characters for tree formatting
```
lsblk -i
```
7. Make lsblk display info about device owner, group, and mode
```
lsblk -m
```
8. Make lsblk output select columns
```
lsblk -o NAME,SIZE
```
## Syntax
```
lsblk [options] [<device> ...]
```
## Reading information given by ``lsblk``
On running ``lsblk`` with no flags or command-line arguments, it writes general disk information to the STDOUT.
Here is a table that interpretes that information:
| Column Name | Meaning | Interpretation |
|:-----------:|:----------------------------------|:------------------------------------------------------------|
| NAME | Name of the device. | Shows name of the device. |
| RM | Removable. | Shows 1 if the device is removable, 0 if not. |
| SIZE | Size of the device. | Shows size of the device. |
| RO | Read-Only. | Shows 1 if read-only, 0 if not. |
| TYPE | The type of block or loop device. | Shows ``disk`` for entire disk and ``part`` for partitions. |
| MOUNTPOINTS | Where the device is mounted. | Shows where the device is mounted. Empty if not mounted. |
## Reading information of a specific device
``lsblk`` can display information of a specific device when the device's absolute path is passed to it.
For example, ``lsblk`` command for displaying the information of the ``sda`` disk is:
```
lsblk /dev/sda
```
## Useful flags for ``lsblk``
Here is a table that show some of the useful flags that can be used with lsblk
| **Short Flag** | **Long Flag** | **Description** |
|:--------------------------:|:-----------------------|:---------------------------------------------|
| ``-a`` | ``--all`` | `lsblk` does not list empty devices by default. This option disables this restriction. |
| ``-b`` | ``--bytes`` | Print the SIZE column in bytes rather than in human-readable format. |
| ``-d`` | ``--nodeps`` | Don't print device holders or slaves. |
| ``-D`` | ``--discard`` | Print information about the discard (TRIM, UNMAP) capabilities for each device. |
| ``-E`` | ``--dedup column`` | Use column as a de-duplication key to de-duplicate output tree. If the key is not available for the device, or the device is a partition and parental whole-disk device provides the same key than the device is always printed.|
| ``-e`` | ``--exclude list`` | xclude the devices specified by a comma-separated list of major device numbers. Note that RAM disks (major=1) are excluded by default. The filter is applied to the top-level devices only.|
| ``-f`` | ``--fs`` | Displays information about filesystem. |
| ``-h`` | ``--help`` | Print a help text and exit.|
| ``-l`` | ``--include list`` | Displays all the information in List Format. |
| ``-J`` | ``--json`` | Displays all the information in JSON Format. |
| ``-l`` | ``--list`` | Displays all the information in List Format. |
| ``-m`` | ``--perms`` | Displays info about device owner, group and mode. |
| ``-M`` | ``--merge`` | Group parents of sub-trees to provide more readable output for RAIDs and Multi-path devices. The tree-like output is required.|
| ``-n`` | ``--noheadings`` | Do not print a header line. |
| ``-o`` | ``--output list`` | Specify which output columns to print. Use `--help` to get a list of all supported columns. |
| ``-O`` | ``--output-all`` | Displays all available columns. |
| ``-p`` | ``--paths`` | Displays absolute device paths. |
| ``-P`` | ``--pairs`` | Use key="value" output format. All potentially unsafe characters are hex-escaped (\x<code>) |
| ``-r`` | ``--raw`` | Use the raw output format. All potentially unsafe characters are hex-escaped (\x<code>) in NAME, KNAME, LABEL, PARTLABEL and MOUNTPOINT columns.|
| ``-S`` | ``--scsi`` | Output info about SCSI devices only. All partitions, slaves and holder devices are ignored.|
| ``-s`` | ``--inverse`` | Print dependencies in inverse order. |
| ``-t`` | ``--topology`` | Output info about block device topology. This option is equivalent to "-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE".|
| ``-T`` | ``--tree[=column]`` | Displays all the information in Tree Format. |
| ``-V`` | ``--version`` | Output version information and exit. |
| ``-w`` | ``--width`` |pecifies output width as a number of characters. The default is the number of the terminal columns, and if not executed ona terminal, then output width is not restricted at all by default.|
| ``-x`` | ``--sort [column]`` | Sort output lines by column. This option enables `--list` output format by default. It is possible to use the option `--tree` to force tree-like output and than the tree branches are sorted by the column.|
| ``-z`` | ``--zoned`` | Print the zone model for each device. |
| ``-`` | ``--sysroot directory``| Gather data for a Linux instance other than the instance from which the lsblk command is issued. The specified directory is the system root of the Linux instance to be inspected.|
## Exit Codes
Like every Unix / Linux Program, ``lslbk`` returns an exit code to the environment.
Here is a table of all the exit codes.
| Exit Code | Meaning |
|:---------:|:-----------------------------------------------------------|
| 0 | Exit with success. |
| 1 | Exit with failure. |
| 32 | Specified device(s) not found. |
| 64 | Some of the specified devices were found while some not. |

View File

@@ -0,0 +1,60 @@
# The `netstat` command
The term `netstat` stands for Network Statistics. In laymans terms, netstat command displays the current network connections, networking protocol statistics, and a variety of other interfaces.
Check if you have `netstat` on your PC:
```
netstat v
```
If you don't have `netstat` installed on your PC, you can install it with the following command:
```
sudo apt install net-tools
```
### You can use `netstat` command for some use cases given below:
- `Netstat` command with `-nr` flag shows the routing table detail on the terminal.
Example:
```
netstat -nr
```
- `Netstat` command with `-i` flag shows statistics for the currently configured network interfaces.
This command will display the first 10 lines of file `foo.txt` .
Example:
```
netstat -i
```
- `Netstat` command with `-tunlp` will gives a list of networks, their current states, and their associated ports.
Example:
```
netstat -tunlp
```
- You can get the list of all TCP port connection by using `-at` with `netstat`.
```
netstat -at
```
- You can get the list of all UDP port connection by using `-au` with `netstat`.
```
netstat -au
```
- You can get the list of all active connection by using `-l` with `netstat`.
```
netstat -l
```

View File

@@ -0,0 +1,54 @@
# The `ps` command
The `ps` command is used to identify programs and processes that are running on the system and the resources they are using.
Its frequently [pipelined](<https://en.wikipedia.org/wiki/Pipeline_(Unix)>) with other commands like `grep` to search for a program/process or `less`
so that the user can analyze the output one page at a time.
Let's say you have a program like openshot which is notorious for hogging system resources when exporting a video, and you want to close it, but the GUI has become unresponsive.
### Example
1. You want to find the PID of openshot and kill it.
```
ps aux | grep openshot
kill - <openshot PID>
```
2. To Show all the running processes:
```
ps -A
```
### Syntax
`ps [options]`
When run without any options, it's useless and will print: `CMD` - the executable processes/(program) running, their `PID` - process ID, `TTY` - terminal type and `Time` - How long the process has utilized the CPU or thread.
### Common Option
If you are going to remember only one thing from this page let it be these three letter `aux`:
`a` - which displays all processes running, including those being run by other users.
`u` - which shows the effective user of a process, i.e. the person whose file access permissions are used by the process.
`x` - which shows processes that do not have a `TTY` associated with them.
### Additional Options:
|**Option** |**Description** |
|:---|:---|
|`a`|Shows list all processes with a terminal (tty)|
|`-A`|Lists all processes. Identical to `-e`|
|`-a`|Shows all processes except both session leaders and processes not associated with a terminal|
|`-d`|Select all processes except session leaders|
|`--deselect`|Shows all processes except those that fulfill the specified conditions. Identical to `-N`|
|`-e`|Lists all processes. Identical to `-A`|
|`-N`|Shows all processes except those that fulfill the specified conditions. Identical to `-deselect`|
|`T`|Select all processes associated with this terminal. Identical to the `-t` option without any argument|
|`r`|Restrict the selection to only running processes|
|`--help simple`|Shows all the basic options|
|`--help all`|Shows every available options|
Another useful command which give a realtime snapshot of the processes and the resources they are using about every ten seconds is `top`.

View File

@@ -0,0 +1,92 @@
# The `top/htop` command
`top` is the default command-line utility that comes pre-installed on Linux distributions and Unix-like operating systems. It is used for displaying information about the system and its top CPU-consuming processes as well as RAM usage.
`htop` is interactive process-viewer and process-manager for Linux and Unix-like operating system based on ncurses. If you take top and put it on steroids, you get htop.
## Comparison between top and htop:
|**Feature** |**top** |**htop** |
|:---|:---|:---|
|Type|Interactive system-monitor, process-viewer and process-manager|Interactive system-monitor, process-viewer and process-manager|
|Operating System|Linux distributions, macOS |Linux distributions, macOS |
|Installation|Built-in and is always there. Also has more adoption due to this fact.|Doesn't come preinstalled on most Linux distros. Manual installation is needed|
|User Interface|Basic text only|Colorful and nicer text-graphics interface|
|Scrolling Support|No|Yes, supports horizontal and vertical scrolling|
|Mouse Support|No|Yes|
|Process utilization|Displays processes but not in tree format|Yes, including user and kernel threads|
|Scrolling Support|No|Yes, supports horizontal and vertical scrolling|
|Mouse Support|No|Yes|
|Process utilization|Displays processes but not in tree format|Yes, including user and kernel threads|
|Network Utilization|No|No|
|Disk Utilization|No|No|
|Comments|Has a learning curve for some advanced options like searching, sending messages to processes, etc. It is good to have some knowledge of top because it is the default process viewer on many systems.|Easier to use and supports vi like searching with `/`. Sending messages to processes (kill, renice) is easier and doesn't require typing in the process number like top.|
## Examples:
### `top`
1. To display dynamic real-time information about running processes:
```
top
```
2. Sorting processes by internal memory size (default order - process ID):
```
top -o mem
```
3. Sorting processes first by CPU, then by running time:
```
top -o cpu -O time
```
4. Display only processes owned by given user:
```
top -user {user_name}
```
### `htop`
1. Display dynamic real-time information about running processes. An enhanced version of `top`.
```
htop
```
2. displaying processes owned by a specific user:
```
htop --user {user_name}
```
3. Sort processes by a specified `sort_item` (use `htop --sort help` for available options):
```
htop --sort {sort_item}
```
## Syntax:
```
top [OPTIONS]
```
```
htop [OPTIONS]
```
## Additional Flags and their Functionalities:
|**Short Flag** |**Long Flag** |**Description** |
|:---|:---|:---|
|`-a`|<center>-</center>|Sort by memory usage.|
|`-b`|<center>-</center>|Batch mode operation. Starts top in 'Batch mode', which could be useful for sending output from top to other programs or to a file. In this mode, top will not accept input and runs until the iterations limit you've set with the '-n' command-line option or until killed.|
|`-h`|<center>-</center>|`top --user {user_name}` Only display processes owned by user.|
|`-U`|<center>-user</center>|Help.|
|`-u`|<center>-</center>|This is an alias equivalent to: -o cpu -O time.|