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,45 @@
# The `crontab` command
`crontab` is used to maintain crontab files for individual users (Vixie Cron)
crontab is the program used to install, uninstall or list the tables used to drive the cron(8) daemon in Vixie Cron. Each user can have their own crontab, and though these are files in `/var/spool/cron/crontabs`, they are not intended to be edited directly.
### Syntax:
```
crontab [ -u user ] file
crontab [ -u user ] [ -i ] { -e | -l | -r }
```
### Examples:
1. The -l option causes the current crontab to be displayed on standard output.
```
crontab -l
```
2. The -r option causes the current crontab to be removed.
```
crontab -r
```
3. The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically. If neither of the environment variables is defined, then the default editor /usr/bin/editor is used.
```
crontab -e
```
4. You can specify the user you want to edit the crontab for. Every user has its own crontab. Assume you have a `www-data` user, which is in fact the user Apache is default running as. If you want to edit the crontab for this user you can run the following command
```
crontab -u www-data -e
```
### Help Command
Run below command to view the complete guide to `crontab` command.
```
man crontab
```

View File

@@ -0,0 +1,114 @@
# The `date` command
The `date` command is used to print the system current date and time.
`date` command is also used to set the date and time of the system, but you need to be the super-user *(root)* to do it.
### Examples:
1. To show the current date and time:
```
date
```
2. You can use -u option to show the date and time in UTC *(Coordinated Universal Time)* time zone
```
date -u
```
1. To display any given date string in formatted date:
```
date --date="2/02/2010"
date --date="2 years ago"
```
### Syntax:
```
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
```
### Additional Flags and their Functionalities:
|**Short Flag** |**Long Flag** |**Description** |
|:---|:---|:---|
|`-d`|`--date=STRING`|convert the provided string into formatted date|
|`-f`|`--file=DATEFILE`|like `--date` but for files|
|`-I[FMT]`|`--iso-8601[=FMT]`|Display date and time in ISO 8601 format|
|`-r`|`--reference=FILE`|Display the last modification time of FILE|
|`-s`|`--set=STRING`|sets the time to the one described by STRING|
|`-u`|`--universal`|show the date and time in UTC *(Coordinated Universal Time)* time zone|
|`-R`|`--rfc-email`|Display date and time in ISO 8601 format Example: (Fri, 22 Oct 2021 05:18:42 +0200)|
|<center>-<center>|`rfc-3339=FMT`|Display date and time in RFC 3339 format|
|<center>-<center>|`--debug`|Usually used with `--date` to annotate the parsed date and warn about questionable usage to stderr|
### Control The output:
You can use Format specifiers to control the output date and time.
### Examples:
|**Command** |**Output** |
|:---|:---|
|`$ date "+%D"`|`10/22/21`|
|`$ date "+%D %T"`|`10/22/21 05:33:51`|
|`$ date "+%A %B %d %T %y"`|`Friday October 22 05:34:47 21`|
### Syntax:
```
date "+%[format-options ...]"
```
### List of Format specifiers to control the output:
|**Specifiers** |**Description** |
|:---|:---|
|`%a`|abbreviated weekday name *(e.g., Sun)*|
|`%A`|full weekday name *(e.g., Sunday)*|
|`%b`|abbreviated month name *(e.g., Jan)*|
|`%B`|full month name *(e.g., January)*|
|`%c`|date and time *(e.g., Thu Mar 3 23:05:25 2005)*|
|`%C`|century; like %Y, except omit last two digits (e.g., 20)|
|`%d`|day of month (e.g., 01)|
|`%D`|date; same as %m/%d/%y|
|`%e`|day of month, space padded; same as %_d|
|`%F`|full date; same as %Y-%m-%d|
|`%g`|last two digits of year of ISO week number (see %G)|
|`%G`|year of ISO week number (see %V); normally useful only with %V|
|`%h`|same as %b|
|`%H`|hour (00..23)|
|`%I`|hour (01..12)|
|`%j`|day of year (001..366)|
|`%k`|hour, space padded ( 0..23); same as %_H|
|`%l`|hour, space padded ( 1..12); same as %_I|
|`%m`|month (01..12)|
|`%M`|minute (00..59)|
|`%n`|a newline|
|`%N`|nanoseconds (000000000..999999999)|
|`%p`|locale's equivalent of either AM or PM; blank if not known|
|`%P`|like %p, but lower case|
|`%q`|quarter of year (1..4)|
|`%r`|locale's 12-hour clock time (e.g., 11:11:04 PM)|
|`%R`|24-hour hour and minute; same as %H:%M|
|`%s`|seconds since 1970-01-01 00:00:00 UTC|
|`%S`|second (00..60)|
|`%t`|a tab|
|`%T`|time; same as %H:%M:%S|
|`%u`|day of week (1..7); 1 is Monday|
|`%U`|week number of year, with Sunday as first day of week (00..53)|
|`%V`|ISO week number, with Monday as first day of week (01..53)|
|`%w`|day of week (0..6); 0 is Sunday|
|`%W`|week number of year, with Monday as first day of week (00..53)|
|`%x`|locale's date representation (e.g., 12/31/99)|
|`%X`|locale's time representation (e.g., 23:13:48)|
|`%y`|last two digits of year (00..99)|
|`%Y`|year|
|`%z`|+hhmm numeric time zone (e.g., -0400)|
|`%:z`|+hh:mm numeric time zone (e.g., -04:00)|
|`%::z`|+hh:mm:ss numeric time zone (e.g., -04:00:00)|
|`%:::z`|numeric time zone with : to necessary precision (e.g., -04, +05:30)|
|`%Z`|alphabetic time zone abbreviation (e.g., EDT)|

View File

@@ -0,0 +1,26 @@
# The `hostname` command
`hostname` is used to display the system's DNS name, and to display or set its hostname or NIS domain name.
### Syntax:
```
hostname [-a|--alias] [-d|--domain] [-f|--fqdn|--long] [-A|--all-fqdns] [-i|--ip-address] [-I|--all-ip-addresses] [-s|--short] [-y|--yp|--nis]
```
### Examples:
1. ``` hostname -a, hostname --alias ```
Display the alias name of the host (if used). This option is deprecated and should not be used anymore.
2. ```hostname -s, hostname --short```
Display the short host name. This is the host name cut at the first dot.
3. ```hostname -V, hostname --version```
Print version information on standard output and exit successfully.
### Help Command
Run below command to view the complete guide to `hostname` command.
```
man hostname
```

View File

@@ -0,0 +1,44 @@
# The `hostnamectl` command
The `hostnamectl` command provides a proper API used to control Linux system hostname and change its related settings. The command also helps to change the hostname without actually locating and editing the `/etc/hostname` file on a given system.
## Syntax
```
$ hostnamectl [OPTIONS...] COMMAND ...
```
where **COMMAND** can be any of the following
**status**: Used to check the current hostname settings
**set-hostname NAME**: Used to set system hostname
**set-icon-name NAME**: Used to set icon name for host
## Example
1. Basic usage to view the current hostnames
```
$ hostnamectl
```
or
```
$ hostnamectl status
```
2. To change the static host name to _myhostname_. It may or may not require root access
```
$ hostnamectl set-hostname myhostname --static
```
3. To set or change a transient hostname
```
$ hostnamectl set-hostname myotherhostname --transient
```
4. To set the pretty hostname. The name that is to be set needs to be in the double quote(” “).
```
$ hostname set-hostname "prettyname" --pretty
```

View File

@@ -0,0 +1,56 @@
# The `reboot` Command
The `reboot` command is used to restart a linux system. However, it requires elevated permission using the [sudo](https://github.com/bobbyiliev/101-linux-commands-ebook/blob/main/ebook/en/content/051-the-sudo-command.md) command. Necessity to use this command usually arises after significant system or network updates have been made to the system.
## Syntax
```
reboot [OPTIONS...]
```
### Options
- **help** : This option prints a short help text and exit.
- **-halt** : This command will stop the machine.
- **-w**, **wtmp-only** : This option only writes wtmp shutdown entry, it do not actually halt, power-off, reboot.
### Examples
1. Basic Usage. Mainly used to restart without any further details
```
$ sudo reboot
```
However, alternatively the shutdown command with the `-r` option
```
$ sudo shutdown -r now
```
**Note** that the usage of the reboot, halt and power off is almost similar in syntax and effect. Run each of these commands with help to see the details.
2. The `reboot` command has limited usage, and the `shutdown` command is being used instead of reboot command to fulfill much more advance reboot and shutdown requirements. One of those situations is a scheduled restart. Syntax is as follows
```
$ sudo shutdown r [TIME] [MESSAGE]
```
Here the TIME has various formats. The simplest one is `now`, already been listed in the previous section, and tells the system to restart immediately. Other valid formats we have are +m, where m is the number of minutes we need to wait until restart and HH:MM which specifies the TIME in a 24hr clock.
**Example to reboot the system in 2 minutes**
```
$ sudo shutdown r +2
```
**Example of a scheduled restart at 03:00 A.M**
```
$ sudo shutdown r 03:00
```
3. Cancelling a Reboot. Usually happens in case one wants to cancel a scheduled restart
**Syntax**
```
$ sudo shutdown c [MESSAGE]
```
**Usage**
```
$sudo shutdown -c "Scheduled reboot cancelled because the chicken crossed the road"
```
4. Checking your reboot logs
```
$ last reboot
```

View File

@@ -0,0 +1,39 @@
# The `shutdown` command
The `shutdown` command lets you bring your system down in a secure way. When `shutdown` is executed the system will notify all logged-in users and disallow further logins.
You have the option to shut down your system immediately or after a specific time.
Only users with root (or sudo) privileges can use the `shutdown` command.
### Examples:
1. Shut down your system immediately:
```
sudo shutdown now
```
2. Shut down your system after 10 minutes:
```
sudo shutdown +10
```
3. Shut down your system with a message after 5 minutes:
```
sudo shutdown +5 "System will shutdown in 5 minutes"
```
### Syntax:
```
shutdown [OPTIONS] [TIME] [MESSAGE]
```
### Additional Flags and their Functionalities:
|**Short Flag** |**Long Flag** |**Description** |
|:---|:---|:---|
|`-r`|<center>-</center>|Reboot the system|
|`-c`|<center>-</center>|Cancel an scheduled shut down|

View File

@@ -0,0 +1,39 @@
# The `su` command
In linux, `su` allows you to run commands with a substitute user and group ID.
When called without arguments, `su` defaults to running an interactive shell as root.
## Example :
```bash
$ su
```
In case that you wanted to switch to a user called `devdojo`, you could do that by running the following command:
```
$ su devdojo
```
## The syntax of the `su` command is :
```bash
$ su [options] [-] [<user>[<argument>...]]
```
## Options :
```bash
-m, -p --> do not reset environment variables
-w --> do not reset specified variables
-g --> specify the primary group
-G --> specify a supplemental group
-l --> make the shell a login shell
-f --> pass -f to the shell (for csh or tcsh)
-s --> run <shell> if /etc/shell allows it
-p --> create a new pseudo terminal
-h --> display this help
-v --> display version
```

View File

@@ -0,0 +1,52 @@
# The `sudo` command
The `sudo` ("substitute user do" or "super user do") command allows a user with proper permissions to execute a command as another user, such as the superuser.
This is the equivalent of "run as administrator" option in Windows. The `sudo` command allows you to elevate your current user account to have root privileges. Also, the root privilege in `sudo` is only valid for a temporary amount of time. Once that time expires, you have to enter your password again to regain root privilege.
> WARNING: Be very careful when using the `sudo` command. You can cause irreversible and catastrophic changes while acting as root!
### Syntax:
```
sudo [-OPTION] command
```
### Additional Flags and their Functionalities:
|**Flag** |**Description** |
|:---|:---|
|`-V`|The -V (version) option causes sudo to print the version number and exit. If the invoking user is already root, the -V option prints out a list of the defaults sudo was compiled with and the machine's local network addresses|
|`-l`|The -l (list) option prints out the commands allowed (and forbidden) the user on the current host.|
|`-L`|The -L (list defaults) option lists out the parameters set in a Defaults line with a short description for each. This option is useful in conjunction with grep.|
|`-h`|The -h (help) option causes sudo to print a usage message and exit.|
|`-v`|If given the `-v` (validate) option, `sudo` updates the user's timestamp, prompting for the user's password if necessary. This extends the sudo timeout for another 5 minutes (or whatever the timeout is set to in sudoers) but does not run a command.|
|`-K`|The -K (sure kill) option to sudo removes the user's timestamp entirely. Likewise, this option does not require a password.|
|`-u`|The -u (user) option causes sudo to run the specified command as a user other than root. To specify a uid instead of a username, use #uid.|
|`-s`|The -s (shell) option runs the shell specified by the SHELL environment variable if it's set or the shell as specified in the file passwd.|
|`--`|The -- flag indicates that sudo should stop processing command line arguments. It is most useful in conjunction with the -s flag.|
## Examples
This command switches your command prompt to the BASH shell as a root user:
```
sudo bash
```
Your command line should change to:
```
root@hostname:/home/[username]
```
Adding a string of text to a file is often used to add the name of a software repository to the sources file, without opening the file for editing. Use the following syntax with echo, sudo and tee command:
```
echo string-of-text | sudo tee -a [path_to_file]
```
Example:
````
echo "deb http://nginx.org/packages/debian `lsb_release -cs` nginx" \ | sudo tee /etc/apt/sources.list.d/nginx.list
````

View File

@@ -0,0 +1,31 @@
# The `uname` command
The `uname` command lets you print out system information and defaults to outputting the kernel name.
## Syntax:
```bash
$ uname [OPTION]
```
## Examples
1. Print out all system information.
```bash
$ uname -a
```
2. Print out the kernel version.
```bash
$ uname -v
```
## Options
|**Short Flag**|**Long Flag**|**Description**|
|:-|:-|:-|
|`-a`|`--all`|Print all information, except omit processor and hardware platform if unknown.|
|`-s`|`--kernel-name`|Print the kernel name.|
|`-n`|`--nodename`|Print the network node hostname.|
|`-r`|`--kernel-release`|Print the kernel release.|
|`-v`|`--kernel-version`|Print the kernel version.|
|`-m`|`--machine`|Print the machine hardware name.|
|`-p`|`--processor`|Print the processor type (non-portable).|
|`-i`|`--hardware-platform`|Print the hardware platform (non-portable).|
|`-o`|`--operating-system`|Print the operating system.|