automated terminal push
All checks were successful
code.softwareshinobi.com-learn/docker.softwareshinobi.com/pipeline/head This commit looks good

This commit is contained in:
2025-06-04 11:50:30 -04:00
parent 5770800032
commit f1997cab0f
195 changed files with 12169 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
# The `cd` command
The `cd` command is used to change the current working directory *(i.e., in which the current user is working)*. The "cd" stands for "**c**hange **d**irectory" and it is one of the most frequently used commands in the Linux terminal.
The `cd` command is often combined with the `ls` command (see chapter 1) when navigating through a system, however, you can also press the `TAB` key two times to list the contents of the new directory you just changed to.
### Examples of uses:
1. Change the current working directory:
```
cd <specified_directory_path>
```
2. Change the current working directory to the home directory:
```
cd ~
```
OR
```
cd
```
3. Change to the previous directory:
```
cd -
```
This will also echo the absolute path of the previous directory.
4. Change the current working directory to the system's root directory:
```
cd /
```
### &#x1F4A1; Quick Tips
Adding a `..` as a directory will allow you to move "up" from a folder:
```
cd ..
```
This can also be done multiple times! For example, to move up three folders:
```
cd ../../../
```
### Syntax:
```
cd [OPTIONS] directory
```
### Additional Flags and Their Functionalities
|**Short flag** |**Long flag** |**Description** |
|:---|:---|:---|
|`-L`|<center>-</center>|Follow symbolic links. By default,`cd` behaves as if the `-L` option is specified.|
|`-P`|<center>-</center>|Dont follow symbolic links.|

View File

@@ -0,0 +1,41 @@
# The `head` command
The `head` command prints the first ten lines of a file.
Example:
```
head filename.txt
```
Syntax:
```
head [OPTION] [FILENAME]
```
### Get a specific number of lines:
Use the `-n` option with a number (should be an integer) of lines to display.
Example:
```
head -n 10 foo.txt
```
This command will display the first ten lines of the file `foo.txt`.
Syntax:
```
head -n <number> foo.txt
```
### Additional Flags and their Functionalities
|**Short Flag** |**Long Flag** |**Description** |
|:---|:---|:---|
|`-c`|`--bytes=[-]NUM`|Print the first NUM bytes of each file; <br>with the leading '-', <br>print all but the last NUM bytes of each file|
|`-n`|`--lines=[-]NUM`|Print the first NUM lines instead of the first 10;<br> with the leading '-', <br>print all but the last NUM lines of each file|
|`-q`|`--quiet, --silent`|Never print headers giving file names|
|`-v`|`--verbose`|Always print headers giving file names|
|`-z`|`--zero-terminated`|Line delimiter is NUL, not newline|
|` `|`--help`| Display this help and exit|
|` `|`--version`|Output version information and exit|

View File

@@ -0,0 +1,56 @@
# The `tail` command
The `tail` command prints the last ten lines of a file.
Example:
```
tail filename.txt
```
Syntax:
```
tail [OPTION] [FILENAME]
```
### Get a specific number of lines with `tail`:
Use the `-n` option with a number(should be an integer) of lines to display.
Example:
```
tail -n 10 foo.txt
```
This command will display the last ten lines of the file `foo.txt`.
### Refresh the output on any new entry in a file
It is possible to let tail output any new line added to the file you are looking into. So, if a new line is written to the file, it will immediately be shown in your output. This can be done using the `--follow` or `-f` option. This is especially useful for monitoring log files.
Example:
```
tail -f foo.txt
```
Syntax:
```
tail -n <number> foo.txt
```
### Additional Flags and their Functionalities
|**Short Flag** |**Long Flag** |**Description** |
|:---|:---|:---|
|`-c`|`--bytes=[+]NUM`|Output the last NUM bytes;<br> or use -c +NUM to <br>output starting with byte NUM of each file|
|`-f`|<code>--follow[={name&#124;descriptor}]</code>|Output appended data as the file grows;<br>an absent option argument means 'descriptor'|
|`-F`||Same as --follow=name --retry|
|`-n`|`--lines=[+]NUM`|Output the last NUM lines, instead of the last 10;<br>or use -n +NUM to output starting with line NUM|
||`--max-unchanged-stats=N`|with --follow=name, reopen a FILE which has not<br>changed size after N (default 5) iterations<br>to see if it has been unlinked or rename<br>(this is the usual case of rotated log files);<br>with inotify, this option is rarely useful|
||`--pid=PID`|with -f, terminate after process ID, PID dies|
|`-q`|`--quiet, --silent`|Never output headers giving file names|
|``|`--retry`|keep trying to open a file if it is inaccessible|
|`-s`|`--sleep-interval=N`|With -f, sleep for approximately N seconds<br>(default 1.0) between iterations;<br>with inotify and --pid=P, check process P at<br>least once every N seconds|
|`-v`|`--verbose`|Always output headers giving file names|
|`-z`|`--zero-terminated`|Line delimiter is NUL, not newline|
||`--help`|Display this help and exit|
||`--version`|Output version information and exit|

View File

@@ -0,0 +1,40 @@
# The `pwd` command
The `pwd` stands for Print Working Directory. It prints the path of the current working directory, starting from the root.
Example:
```
pwd
```
The output would be your current directory:
```
/home/your_user/some_directory
```
Syntax:
```
pwd [OPTION]
```
Tip:
You can also check this by printing out the `$PWD` variable:
```
echo $PWD
```
The output would be the same as of the `pwd` command.
### Options:
|**Short Flag** |**Long Flag** |**Description** |
|:---|:---|:---|
| `-L` | `--logical` | If the environment variable $PWD contains an absolute name of the current directory with no "." or ".." components, then output those contents, even if they contain symbolic links. Otherwise, fall back to default (-P) behavior. |
| `-P`| `--physical` | Print a fully resolved name for the current directory, where all components of the name are actual directory names, and not symbolic links. |
| ` ` | `--help`| Display a help message, and exit. |
| ` ` | `--version`| Display version information, and exit. |
By default, `pwd' behaves as if `-L' were specified.

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,45 @@
# The `echo` command
The `echo` command lets you display the line of text/string that is passed as an argument
### Examples:
1. To Show the line of text or string passed as an argument:
```
echo Hello There
```
2. To show all files/folders similar to the `ls` command:
```
echo *
```
3. To save text to a file named foo.bar:
```
echo "Hello There" > foo.bar
```
4. To append text to a file named foo.bar:
```
echo "Hello There" >> foo.bar
```
### Syntax:
```
echo [option] [string]
```
#### It is usually used in shell scripts and batch files to output status text to the screen or a file.The `-e` used with it enables the interpretation of backslash escapes
### Additional Options and their Functionalities:
|**Option** |**Description** |
|:---|:---|
|`\b`|removes all the spaces in between the text|
|`\c`|suppress trailing new line with backspace interpretor -e to continue without emitting new line.|
|`\n`|creates new line from where it is used|
|`\t`|creates horizontal tab spaces|
|`\r`|carriage returns with backspace interpretor -e to have specified carriage return in output|
|`\v`|creates vertical tab spaces|
|`\a`|alert returns with a backspace interpretor -e to have sound alert|
|`-n`|omits echoing trailing newline .|

View File

@@ -0,0 +1,19 @@
# The `history` command
If you type `history` you will get a list of the last 500 commands used. This gives you the possibility to copy and paste commands that you executed in the past.
This is powerful in combination with grep. So you can search for a command in your command history.
### Examples:
1. If you want to search in your history for artisan commands you ran in the past.
```
history | grep artisan
```
2. If you only want to show the last 10 commands you can.
```
history 10
```

View File

@@ -0,0 +1,30 @@
# The `clear` command
In linux, the `clear` command is used to clear terminal screen.
## Example
```bash
$ clear
```
## Before:
```bash
$ echo Hello World
Hello World
$ clear
```
## After executing clear command:
```bash
$
```
Screenshot:
![clear command in linux example](https://user-images.githubusercontent.com/21223421/135708520-5fb54205-39ce-4e9c-b376-7569d0c4420d.png)
After running the command your terminal screen will be clear:
![clear command in linux](https://user-images.githubusercontent.com/21223421/135708538-f01de268-3cf6-4f3a-a32b-a14fb67575f1.png)

View File

@@ -0,0 +1,25 @@
# The `yes` command
The `yes` command in linux is used to print a continuous output stream of given _STRING_. If _STRING_ is not mentioned then it prints y. It outputs a string repeatedly unit killed (using something like ctrl + c).
### Examples :
1. Prints hello world infinitely in the terminal until killed :
```
yes hello world
```
2. A more generalized command:
```
yes [STRING]
```
## Options
It accepts the following options:
1. --help
> display this help and exit
2. --version
> output version information and exit

View File

@@ -0,0 +1,10 @@
# The `exit` command
The `exit` command is used to terminate (close) an active shell session
### Syntax:
```
exit
```
***Shortcut:** Instead of typing `exit`, press `ctrl + D`, it will do the same Functionality.*

View File

@@ -0,0 +1,31 @@
# The `sleep` command
The `sleep` command is used to create a dummy job. A dummy job helps in delaying the execution. It takes time in seconds by default but a small suffix(s, m, h, d) can be added at the end to convert it into any other format. This command pauses the execution for an amount of time which is defined by NUMBER.
Note: If you will define more than one NUMBER with sleep command then this command will delay for the sum of the values.
### Examples :
1. To sleep for 10s
```
sleep 10s
```
2. A more generalized command:
```
sleep NUMBER[SUFFIX]...
```
## Options
It accepts the following options:
1. --help
> display this help and exit
2. --version
> output version information and exit
---

View File

@@ -0,0 +1,90 @@
# The `xargs` command
`xargs` is used to build and execute command lines from standard input
Some commands like grep can accept input as parameters, but some commands accepts arguments, this is place where xargs came into picture.
### Syntax:
```
xargs [options] [command [initial-arguments]]
```
### Options:
```
-0, --null
```
Input items are terminated by a null character instead of by whitespace, and the quotes and backslash are not special (every character is taken literally). Disables the end of file string, which is treated like any other argument. Useful when input items might contain white space, quote marks, or backslashes.
```
-a file, --arg-file=file
```
Read items from file instead of standard input. If you use this option, stdin remains unchanged when commands are run. Otherwise, stdin is redirected
from /dev/null.
```
-o, --open-tty
```
Reopen stdin as /dev/tty in the child process before executing the command. This is useful if you want xargs to run an interactive application.
```
--delimiter=delim, -d delim
```
Input items are terminated by the specified character. The specified delimiter may be a single character, a C-style character escape such as \n, or an
octal or hexadecimal escape code. Octal and hexadecimal escape codes are understood as for the printf command. Multibyte characters are not supported.
When processing the input, quotes and backslash are not special; every character in the input is taken literally. The -d option disables any end-of-file
string, which is treated like any other argument. You can use this option when the input consists of simply newline-separated items, although it is al
most always better to design your program to use --null where this is possible.
```
-p, --interactive
```
Prompt the user about whether to run each command line and read a line from the terminal. Only run the command line if the response starts with `y' or
`Y'. Implies -t.
### Examples:
```
find /tmp -name core -type f -print | xargs /bin/rm -f
```
Find files named core in or below the directory /tmp and delete them. Note that this will work incorrectly if there are any filenames containing newlines or
spaces.
```
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
```
Find files named core in or below the directory /tmp and delete them, processing filenames in such a way that file or directory names containing spaces or new
lines are correctly handled.
```
find /tmp -depth -name core -type f -delete
```
Find files named core in or below the directory /tmp and delete them, but more efficiently than in the previous example (because we avoid the need to use fork(2)
and exec(2) to launch rm and we don't need the extra xargs process).
```
cut -d: -f1 < /etc/passwd | sort | xargs echo
```
Generates a compact listing of all the users on the system.
### Help Command
Run below command to view the complete guide to `xargs` command.
```
man xargs
```

View File

@@ -0,0 +1,62 @@
# The `grep` command
The `grep` filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern.
grep stands for globally search for regular expression and print out. The pattern that is searched in the file is referred to as the regular expression.
### Examples:
1. To search the contents of the destination.txt file for a string("KeY") case insensitively.
```
grep -i "KeY" destination.txt
```
2. Displaying the count of number of matches
```
grep -c "key" destination.txt
```
3. We can search multiple files and only display the files that contains the given string/pattern.
```
grep -l "key" destination1.txt destination2.txt destination3.xt destination4.txt
```
4. To show the line number of file with the line matched.
```
grep -n "key" destination.txt
```
5. If you want to grep the monitored log files, you can add the `--line-buffered` to search them in real time.
```
tail -f destination.txt | grep --line-buffered "key"
```
### Syntax:
The general syntax for the grep command is as follows:
```
grep [options] pattern [files]
```
### Additional Flags and their Functionalities:
| **Short Flag** | **Long Flag** | **Description** |
| :------------- | :--------------------- | :---------------------------------------------------------------------------------------------- |
| `-c` | `--count` | print a count of matching lines for each input file |
| `-h` | `--no-filename` | Display the matched lines, but do not display the filenames |
| `-i` | `--ignore-case` | Ignores, case for matching |
| `-l` | `--files-with-matches` | Displays list of a filenames only. |
| `-n` | `--line-number` | Display the matched lines and their line numbers. |
| `-v` | `--invert-match` | This prints out all the lines that do not matches the pattern |
| `-e` | `--regexp=` | Specifies expression with this option. Can use multiple times |
| `-f` | `--file=` | Takes patterns from file, one per line. |
| `-F` | `--fixed-strings=` | Interpret patterns as fixed strings, not regular expressions. |
| `-E` | `--extended-regexp` | Treats pattern as an extended regular expression (ERE) |
| `-w` | `--word-regexp` | Match whole word |
| `-o` | `--only-matching` | Print only the matched parts of a matching line, with each such part on a separate output line. |
| | `--line-buffered` | Force output to be line buffered. |

View File

@@ -0,0 +1,58 @@
# The `alias` command
The `alias` command lets you create shortcuts for commands or define your own commands.
This is mostly used to avoid typing long commands.
### Examples:
1. To show the list of all defined aliases in the reusable form `alias NAME=VALUE` :
```
alias -p
```
2. To make `ls -A` shortcut:
```
alias la='ls -A'
```
### Syntax:
```
alias [-p] [name[=value]]
```
### Setting Persistent Options:
As with most Linux custom settings for the terminal, any alias you defined is only applied to the current opening terminal session.
For any alias to be active for all new sessions you need to add that command to your rc file to be executed in the startup of every new terminal.
this file can be as follows:
- **Bash**: ~/.bashrc
- **ZSH**: ~/.zshrc
- **Fish** ~/.config/fish/config.fish
you can open that file with your favorite editor as follows:
```
vim ~/.bashrc
```
type your commands one per line, then save the file and exit.
the commands will be automatically applied in the next session.
If you want to apply it in the current session, run the following command:
```
source ~/.bashrc
```
### Opposite command:
To remove predefined alias you can use `unalias` command as follows:
```
unalias alias_name
```
to remove all aliases
```
unalias -a
```

View File

@@ -0,0 +1,45 @@
# The `less` command
The less command is a Linux terminal pager which shows a file's content one screen at a time.
Useful when dealing with a large text file because it doesn't load the entire file but accesses it page by page, resulting in fast loading speeds.
## Syntax
```
less [options] file_path
```
## Options
Some popular option flags include:
```
-E less automatically exits upon reaching the end of file.
-f Forces less to open non-regular files (a directory or a device-special file).
-F Exit less if the entire file can be displayed on the first screen.
-g Highlights the string last found using search. By default, less highlights all strings matching the last search command.
-G Removes all highlights from strings found using search.
```
For a complete list of options, refer to the less help file by running:
```
less --help
```
## Few Examples:
1. Open a Text File
```
less /etc/updatedb.conf
```
2. Show Line Numbers
```
less -N /etc/init/mysql.conf
```
3. Open File with Pattern Search
```
less -pERROR /etc/init/mysql.conf
```
4. Remove Multiple Blank Lines
```
less welcome.txt
```
Here I showed you how to use the less command in Linux. Although there are other terminal pagers, such as most and more, but less could be a better choice as it is a powerful tool present in almost every system.
For more details: https://phoenixnap.com/kb/less-command-in-linux#:~:text=The%20less%20command%20is%20a,resulting%20in%20fast%20loading%20speeds.