# General Linux Commands

Commands and General functions | In Terminal

# General Linux Commands | In terminal

- Check operating system  
    `cat/etc/*rel*`

- Check system info 
    - CPU  
        
        - `cat /proc/cpuinfo`
    - Memory 
        - `cat /proc/meminfo`

- ports - Check for listening ports.   
    `netstat -tulpn`
- Check users and passwords (PUID and)  
    `getent passwd`
- change ownership of directory/folder or file 
    - directory / folder 
        - `chown root:root filename/`
        - `chown -R root:root filename/ ` (all sub folders/files)
    - files 
        - `chmod 775 filename/`

#### Check file size and other info: Different ways to check for files size

- `ls -lh `  
    \- `ls -l` filename #check size of the specified file (bytes)  
    \- `ls -l` \* #check size of all the files in the current directory ```
    apt-get update
    ```
    
      
    \- `ls -al` \* #check size of all the files including hidden files in the current directory  
    \- `ls -al` dir/ #check size of all the files including hidden files in the ‘dir’ directory  
    \- `du -sh` filename   
    \- `du -sh -- *` Shows disk space usage  
    - `df -h .` Shows free disk space

##### Show block devises | show drives

```bash
lsblk
```

Show drive serial numbers

```
lsblk --nodeps -o name,serial
```

#### Minimize: Go back to terminal without getting out of your doc

`Ctrl=Z`  
To go back to the doc `fg` Press enter

#### Copy File from Host to Container

`docker cp doc.txt container_id:/doc.txt`  
 Copy host-file-name container\_id:/new-file-name.txt

#### Run docker-compose from another directory  


`docker-compose -f /tmp/myproject/docker-compose.yml up -d`

##### Updating:

Debian:

update the package index files in Linux to get the latest list of available packages in the repositories.

```
apt-get update
```

upgrade currently installed software packages to their latest versions. Under no circumstances are existing packages removed:

```
apt-get upgrade
```

enhanced version of the apt-upgrade command. Apart from upgrading existing software packages, it installs and removes some packages to satisfy some dependencies.

```
apt-get 
```

#### Computer susbend / wakeup automatically 

sudo rtcwake -m \[type of suspend\] -s \[number of seconds\]  
`sudo rtcwake -m 5 -s 30`

##### Disk shutoff for 60 seconds

`sudo rtcwake -m disk -s 60`

##### Disk shutoff and turn on later

`sudo rtcwake -m no -l -t $(date +%s -d 'tomorrow 09:00')`

#### Types of Suspend

The `-m` switch accepts the following types of suspend:

`standby` – Standby offers little power savings, but restoring to a running system is very quick. This is the default mode if you omit the -m switch.

`mem` – Suspend to RAM. This offers significant power savings – everything is put into a low-power state, except your RAM. The contents of your memory are preserved.

`disk` – Suspend to disk. The contents of your memory are written to disk and your computer is powered off. The computer will turn on and its state will be restored when the timer completes.

`off` – Turn the computer off completely. rtcwake’s man page notes that restoring from “off” isn’t officially supported by the ACPI specification, but this works with many computers anyway.

`no` – Don’t suspend the computer immediately, just set the wakeup time. For example, you could tell your computer to wake up at 6am. After that, can put it to sleep manually at 11pm or 1am – either way, it will wake up at 6am.

Seconds vs. Specific Time  
`-s` this option takes a number of seconds in the future. For example, -s 60 wakes your computer up in 60 seconds, while -s 3600 wakes your computer up in an hour.

`-t` this option allows you to wake your computer up at a specific time. This switch wants a number of seconds since the Unix epoch (00:00:00 UTC on January 1, 1970). To easily provide the correct number of seconds, combine the \*\*date\*\* command with the rtcwake command.

`-l` this switch tells rtcwake that the hardware clock is set to local time, while the \*\*-u\*\* switch tells rtcwake that the hardware clock (in your computer’s BIOS) is set to UTC time. Linux distributions often set your hardware clock to UTC time and translate that to your local time.

make a \[\[Cronjob\]\]

# Time In Linux | setting time zones

Check your timezone on Linux by typing in `timedatectl` command.

Output:

```c++
$ timedatectl

                      Local time: Wed 2019-10-16 22:26:23 UTC
                  Universal time: Wed 2019-10-16 22:26:23 UTC
                        RTC time: Wed 2019-10-16 22:26:24
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: no
systemd-timesyncd.service active: inactive
                 RTC in local TZ: no
```

If you don't know your time zone, find it and copy it.

```c++
timedatectl list-timezones
```

Set your time zone:

```c++
timedatectl set-timezone America/New_York
```

Make sure it worked:

```c++
timedatectl
```

Or

Go here. It tells you everything you need there.   
\- [https://devconnected.com/how-to-set-date-and-time-on-linux/](https://devconnected.com/how-to-set-date-and-time-on-linux/)

# BASH | General commands

  
When running bash scripts, you can include other commands on the same line by using these at the end of each "line" command.   
  
bash:

```
A; B    # Run A and then B, regardless of success of A
A && B  # Run B if and only if A succeeded
A || B  # Run B if and only if A failed
A &     # Run A in background.
```

Example:   
`apt install vim -y A && B apt update vim -y`

Running a bash script file .sh:

```
sh scriptfilename.sh
```

If you get a "Permission denied" error, either run "sudo" or you may need to make the script executable by running

```
chmod +x scriptname.sh
```

# Nginx | General Commands

#### A few commands Nginx

`systemctl start nginx`  
`systemctl stop nginx`  
`systemctl restart nginx`  
`systemctl status nginx`

#### Troubleshooting Nginx

```bash
sudo tail -f /var/log/nginx/error.log
```

```bash
sudo tail -f /var/log/odoo/odoo.log
```

##### Check connection

```bash
curl -I http://<your-external-ip>:80
```

```
curl -I https://<your-external-ip>:443
```

# Docker | General Commands

#### Do you have docker?

`docker -v`

Install Docker: `apt install docker`

Do you have docker-compose? `docker-compose -v`

Docker in Linux Commands (From outside containers):  
`docker images`  
`docker ps -a`  
`docker ps`  
`docker`

#### Go into a Container  


Standard login:

```bash
sudo docker exec -it containername bash
```

Log in as root:

```bash
docker exec -it --user root containername bash
```

To log in as root you can do it this way.

```bash
sudo docker exec -u 0 -it containername bash
```

#### Run docker from different directory:  


`sudo docker-compose -f /directory/to/file/docker-compose.yml up -d`

# Linux command line: bash + utilities

<table class="az" id="bkmrk-a-%26-start-a-new-proc"><tbody><tr><td>A</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[&amp;](https://ss64.com/bash/bg.html)</td><td>Start a new process in the background</td></tr><tr><td>  
</td><td>[alias](https://ss64.com/bash/alias.html)</td><td>Create an alias •</td></tr><tr><td>  
</td><td>[apropos](https://ss64.com/bash/apropos.html)</td><td>Search Help manual pages (man -k)</td></tr><tr><td>  
</td><td>[apt](https://ss64.com/bash/apt.html)</td><td>Search for and install software packages (Debian/Ubuntu)</td></tr><tr><td>  
</td><td>[apt-get](https://ss64.com/bash/apt-get.html)</td><td>Search for and install software packages (Debian/Ubuntu)</td></tr><tr><td>  
</td><td>[aptitude](https://ss64.com/bash/aptitude.html)</td><td>Search for and install software packages (Debian/Ubuntu)</td></tr><tr><td>  
</td><td>[aspell](https://ss64.com/bash/aspell.html)</td><td>Spell Checker</td></tr><tr><td>  
</td><td>[at](https://ss64.com/bash/at.html)</td><td>Schedule a command to run once at a particular time</td></tr><tr><td>  
</td><td>[awk](https://ss64.com/bash/awk.html)</td><td>Find and Replace text, database sort/validate/index</td></tr><tr><td><a id="bkmrk--0"></a>B</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[basename](https://ss64.com/bash/basename.html)</td><td>Strip directory and suffix from filenames</td></tr><tr><td>  
</td><td>[base32](https://ss64.com/bash/base32.html)</td><td>Base32 encode/decode data and print to standard output</td></tr><tr><td>  
</td><td>[base64](https://ss64.com/bash/base64.html)</td><td>Base64 encode/decode data and print to standard output</td></tr><tr><td>  
</td><td>[bash](https://ss64.com/bash/bash.html)</td><td>GNU Bourne-Again SHell</td></tr><tr><td>  
</td><td>[bc](https://ss64.com/bash/bc.html)</td><td>Arbitrary precision calculator language</td></tr><tr><td>  
</td><td>[bg](https://ss64.com/bash/bg.html)</td><td>Send to background</td></tr><tr><td>  
</td><td>[bind](https://ss64.com/bash/bind.html)</td><td>Set or display readline key and function bindings •</td></tr><tr><td>  
</td><td>[break](https://ss64.com/bash/break.html)</td><td>Exit from a loop •</td></tr><tr><td>  
</td><td>[builtin](https://ss64.com/bash/builtin.html)</td><td>Run a shell builtin</td></tr><tr><td>  
</td><td>[bzip2](https://ss64.com/bash/bzip2.html)</td><td>Compress or decompress named file(s)</td></tr><tr><td><a id="bkmrk--1"></a>C</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[cal](https://ss64.com/bash/cal.html)</td><td>Display a calendar</td></tr><tr><td>  
</td><td>[caller](https://ss64.com/bash/caller.html)</td><td>Return the context of any active subroutine call •</td></tr><tr><td>  
</td><td>[case](https://ss64.com/bash/case.html)</td><td>Conditionally perform a command</td></tr><tr><td>  
</td><td>[cat](https://ss64.com/bash/cat.html)</td><td>Concatenate and print (display) the content of files</td></tr><tr><td>  
</td><td>[cd](https://ss64.com/bash/cd.html)</td><td>Change Directory</td></tr><tr><td>  
</td><td>[cfdisk](https://ss64.com/bash/cfdisk.html)</td><td>Partition table manipulator for Linux</td></tr><tr><td>  
</td><td>[chattr](https://ss64.com/bash/chattr.html)</td><td>Change file attributes on a Linux file system</td></tr><tr><td>  
</td><td>[chgrp](https://ss64.com/bash/chgrp.html)</td><td>Change group ownership</td></tr><tr><td>  
</td><td>[chmod](https://ss64.com/bash/chmod.html)</td><td>Change access permissions</td></tr><tr><td>  
</td><td>[chown](https://ss64.com/bash/chown.html)</td><td>Change file owner and group</td></tr><tr><td>  
</td><td>[chpasswd](https://ss64.com/bash/chpasswd.html)</td><td>Update passwords in batch mode</td></tr><tr><td>  
</td><td>[chroot](https://ss64.com/bash/chroot.html)</td><td>Run a command with a different root directory</td></tr><tr><td>  
</td><td>[chkconfig](https://ss64.com/bash/chkconfig.html)</td><td>System services (runlevel)</td></tr><tr><td>  
</td><td>[cksum](https://ss64.com/bash/cksum.html)</td><td>Print CRC checksum and byte counts</td></tr><tr><td>  
</td><td>clear</td><td>Clear terminal screen</td></tr><tr><td>  
</td><td>[cmp](https://ss64.com/bash/cmp.html)</td><td>Compare two files</td></tr><tr><td>  
</td><td>[comm](https://ss64.com/bash/comm.html)</td><td>Compare two sorted files line by line</td></tr><tr><td>  
</td><td>[command](https://ss64.com/bash/command.html)</td><td>Run a command - ignoring shell functions •</td></tr><tr><td>  
</td><td>[continue](https://ss64.com/bash/continue.html)</td><td>Resume the next iteration of a loop •</td></tr><tr><td>  
</td><td>[cp](https://ss64.com/bash/cp.html)</td><td>Copy one or more files to another location</td></tr><tr><td>  
</td><td>[cpio](https://ss64.com/bash/cpio.html)</td><td>Copy files to and from archives</td></tr><tr><td>  
</td><td>[cron](https://ss64.com/bash/cron.html)</td><td>Daemon to execute scheduled commands</td></tr><tr><td>  
</td><td>[crontab](https://ss64.com/bash/crontab.html)</td><td>Schedule a command to run at a later time</td></tr><tr><td>  
</td><td>[csplit](https://ss64.com/bash/csplit.html)</td><td>Split a file into context-determined pieces</td></tr><tr><td>  
</td><td>[curl](https://ss64.com/bash/curl.html)</td><td>Transfer data from or to a server</td></tr><tr><td>  
</td><td>[cut](https://ss64.com/bash/cut.html)</td><td>Divide a file into several parts</td></tr><tr><td><a id="bkmrk--2"></a>D</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[date](https://ss64.com/bash/date.html)</td><td>Display or change the date &amp; time</td></tr><tr><td>  
</td><td>[dc](https://ss64.com/bash/dc.html)</td><td>Desk Calculator</td></tr><tr><td>  
</td><td>[dd](https://ss64.com/bash/dd.html)</td><td>Data Duplicator - convert and copy a file, write disk headers, boot records</td></tr><tr><td>  
</td><td>[ddrescue](https://ss64.com/bash/ddrescue.html)</td><td>Data recovery tool</td></tr><tr><td>  
</td><td>[declare](https://ss64.com/bash/declare.html)</td><td>Declare variables and give them attributes •</td></tr><tr><td>  
</td><td>[df](https://ss64.com/bash/df.html)</td><td>Display free disk space</td></tr><tr><td>  
</td><td>[diff](https://ss64.com/bash/diff.html)</td><td>Display the differences between two files</td></tr><tr><td>  
</td><td>[diff3](https://ss64.com/bash/diff3.html)</td><td>Show differences among three files</td></tr><tr><td>  
</td><td>[dig](https://ss64.com/bash/dig.html)</td><td>DNS lookup</td></tr><tr><td>  
</td><td>[dir](https://ss64.com/bash/dir.html)</td><td>Briefly list directory contents</td></tr><tr><td>  
</td><td>[dircolors](https://ss64.com/bash/dircolors.html)</td><td>Colour setup for 'ls'</td></tr><tr><td>  
</td><td>[dirname](https://ss64.com/bash/dirname.html)</td><td>Convert a full pathname to just a path</td></tr><tr><td>  
</td><td>[dirs](https://ss64.com/bash/dirs.html)</td><td>Display list of remembered directories</td></tr><tr><td>  
</td><td>[dos2unix](https://ss64.com/bash/dos2unix.html)</td><td>Windows/MAC to UNIX text file format converter</td></tr><tr><td>  
</td><td>[dmesg](https://ss64.com/bash/dmesg.html)</td><td>Print kernel &amp; driver messages</td></tr><tr><td>  
</td><td>[dpkg](https://ss64.com/bash/dpkg.html)</td><td>Package manager (Debian/Ubuntu).</td></tr><tr><td>  
</td><td>[du](https://ss64.com/bash/du.html)</td><td>Estimate file space usage</td></tr><tr><td><a id="bkmrk--3"></a>E</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[echo](https://ss64.com/bash/echo.html)</td><td>Display message on screen •</td></tr><tr><td>  
</td><td>[egrep](https://ss64.com/bash/egrep.html)</td><td>Search file(s) for lines that match an extended expression</td></tr><tr><td>  
</td><td>[eject](https://ss64.com/bash/eject.html)</td><td>Eject removable media</td></tr><tr><td>  
</td><td>[enable](https://ss64.com/bash/enable.html)</td><td>Enable and disable builtin shell commands •</td></tr><tr><td>  
</td><td>[env](https://ss64.com/bash/env.html)</td><td>Environment variables</td></tr><tr><td>  
</td><td>ethtool</td><td>Ethernet card settings</td></tr><tr><td>  
</td><td>[eval](https://ss64.com/bash/eval.html)</td><td>Evaluate several commands/arguments</td></tr><tr><td>  
</td><td>[exec](https://ss64.com/bash/exec.html)</td><td>Execute a command</td></tr><tr><td>  
</td><td>[exit](https://ss64.com/bash/exit.html)</td><td>Exit the shell</td></tr><tr><td>  
</td><td>[expand](https://ss64.com/bash/expand.html)</td><td>Convert tabs to spaces</td></tr><tr><td>  
</td><td>[export](https://ss64.com/bash/export.html)</td><td>Set an environment variable</td></tr><tr><td>  
</td><td>[expr](https://ss64.com/bash/expr.html)</td><td>Evaluate expressions</td></tr><tr><td><a id="bkmrk--4"></a>F</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[false](https://ss64.com/bash/false.html)</td><td>Do nothing, unsuccessfully</td></tr><tr><td>  
</td><td>[fdformat](https://ss64.com/bash/fdformat.html)</td><td>Low-level format a floppy disk</td></tr><tr><td>  
</td><td>[fdisk](https://ss64.com/bash/fdisk.html)</td><td>Partition table manipulator for Linux</td></tr><tr><td>  
</td><td>[fg](https://ss64.com/bash/fg.html)</td><td>Send job to foreground</td></tr><tr><td>  
</td><td>[fgrep](https://ss64.com/bash/fgrep.html)</td><td>Search file(s) for lines that match a fixed string</td></tr><tr><td>  
</td><td>[file](https://ss64.com/bash/file.html)</td><td>Determine file type</td></tr><tr><td>  
</td><td>[find](https://ss64.com/bash/find.html)</td><td>Search for files that meet a desired criteria</td></tr><tr><td>  
</td><td>[fmt](https://ss64.com/bash/fmt.html)</td><td>Reformat paragraph text</td></tr><tr><td>  
</td><td>[fold](https://ss64.com/bash/fold.html)</td><td>Wrap text to fit a specified width</td></tr><tr><td>  
</td><td>[for](https://ss64.com/bash/for.html)</td><td>Expand *words*, and execute *commands*</td></tr><tr><td>  
</td><td>format</td><td>Format disks or tapes</td></tr><tr><td>  
</td><td>free</td><td>Display memory usage</td></tr><tr><td>  
</td><td>[fsck](https://ss64.com/bash/fsck.html)</td><td>File system consistency check and repair</td></tr><tr><td>  
</td><td>[ftp](https://ss64.com/bash/ftp.html)</td><td>File Transfer Protocol</td></tr><tr><td>  
</td><td>[function](https://ss64.com/bash/function.html)</td><td>Define Function Macros</td></tr><tr><td>  
</td><td>[fuser](https://ss64.com/bash/fuser.html)</td><td>Identify/kill the process that is accessing a file</td></tr><tr><td><a id="bkmrk--5"></a>G</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[gawk](https://ss64.com/bash/awk.html)</td><td>Find and Replace text within file(s)</td></tr><tr><td>  
</td><td>[getopts](https://ss64.com/bash/getopts.html)</td><td>Parse positional parameters</td></tr><tr><td>  
</td><td>[getfacl](https://ss64.com/bash/getfacl.html)</td><td>Get file access control lists</td></tr><tr><td>  
</td><td>[grep](https://ss64.com/bash/grep.html)</td><td>Search file(s) for lines that match a given pattern</td></tr><tr><td>  
</td><td>[groupadd](https://ss64.com/bash/groupadd.html)</td><td>Add a user security group</td></tr><tr><td>  
</td><td>[groupdel](https://ss64.com/bash/groupdel.html)</td><td>Delete a group</td></tr><tr><td>  
</td><td>[groupmod](https://ss64.com/bash/groupmod.html)</td><td>Modify a group</td></tr><tr><td>  
</td><td>[groups](https://ss64.com/bash/groups.html)</td><td>Print group names a user is in</td></tr><tr><td>  
</td><td>[gzip](https://ss64.com/bash/gzip.html)</td><td>Compress or decompress named file(s)</td></tr><tr><td><a id="bkmrk--6"></a>H</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[hash](https://ss64.com/bash/hash.html)</td><td>Remember the full pathname of a name argument</td></tr><tr><td>  
</td><td>[head](https://ss64.com/bash/head.html)</td><td>Output the first part of file(s)</td></tr><tr><td>  
</td><td>help</td><td>Display help for a built-in command •</td></tr><tr><td>  
</td><td>[history](https://ss64.com/bash/history.html)</td><td>Command History</td></tr><tr><td>  
</td><td>[hostname](https://ss64.com/bash/hostname.html)</td><td>Print or set system name</td></tr><tr><td>  
</td><td>[htop](https://ss64.com/bash/htop.html)</td><td>Interactive process viewer</td></tr><tr><td><a id="bkmrk--7"></a>I</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[iconv](https://ss64.com/bash/iconv.html)</td><td>Convert the character set of a file</td></tr><tr><td>  
</td><td>[id](https://ss64.com/bash/id.html)</td><td>Print user and group id's</td></tr><tr><td>  
</td><td>[if](https://ss64.com/bash/if.html)</td><td>Conditionally perform a command</td></tr><tr><td>  
</td><td>[ifconfig](https://ss64.com/bash/ifconfig.html)</td><td>Configure a network interface</td></tr><tr><td>  
</td><td>[ifdown](https://ss64.com/bash/ifup.html)</td><td>Stop a network interface</td></tr><tr><td>  
</td><td>[ifup](https://ss64.com/bash/ifup.html)</td><td>Start a network interface up</td></tr><tr><td>  
</td><td>[import](https://ss64.com/bash/import.html)</td><td>Capture an X server screen and save the image to file</td></tr><tr><td>  
</td><td>[install](https://ss64.com/bash/install.html)</td><td>Copy files and set attributes</td></tr><tr><td>  
</td><td>[iostat](https://ss64.com/bash/iostat.html)</td><td>Report CPU and i/o statistics</td></tr><tr><td>  
</td><td>[ip](https://ss64.com/bash/ip.html)</td><td>Routing, devices and tunnels</td></tr><tr><td><a id="bkmrk--8"></a>J</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[jobs](https://ss64.com/bash/jobs.html)</td><td>List active jobs •</td></tr><tr><td>  
</td><td>[join](https://ss64.com/bash/join.html)</td><td>Join lines on a common field</td></tr><tr><td><a id="bkmrk--9"></a>K</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[kill](https://ss64.com/bash/kill.html)</td><td>Kill a process by specifying its PID</td></tr><tr><td>  
</td><td>[killall](https://ss64.com/bash/killall.html)</td><td>Kill processes by name</td></tr><tr><td>  
</td><td>[klist](https://ss64.com/bash/klist.html)</td><td>List cached Kerberos tickets</td></tr><tr><td><a id="bkmrk--10"></a>L</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[less](https://ss64.com/bash/less.html)</td><td>Display output one screen at a time</td></tr><tr><td>  
</td><td>[let](https://ss64.com/bash/let.html)</td><td>Perform arithmetic on shell variables •</td></tr><tr><td>  
</td><td>[link](https://ss64.com/bash/link.html)</td><td>Create a link to a file</td></tr><tr><td>  
</td><td>[ln](https://ss64.com/bash/ln.html)</td><td>Create a symbolic link to a file</td></tr><tr><td>  
</td><td>[local](https://ss64.com/bash/local.html)</td><td>Create a function variable •</td></tr><tr><td>  
</td><td>[locate](https://ss64.com/bash/locate.html)</td><td>Find files</td></tr><tr><td>  
</td><td>[logname](https://ss64.com/bash/logname.html)</td><td>Print current login name</td></tr><tr><td>  
</td><td>[logout](https://ss64.com/bash/logout.html)</td><td>Exit a login shell •</td></tr><tr><td>  
</td><td>[look](https://ss64.com/bash/look.html)</td><td>Display lines beginning with a given string</td></tr><tr><td>  
</td><td>[lpc](https://ss64.com/bash/lpc.html)</td><td>Line printer control program</td></tr><tr><td>  
</td><td>[lpr](https://ss64.com/bash/lpr.html)</td><td>Print files</td></tr><tr><td>  
</td><td>lprint</td><td>Print a file</td></tr><tr><td>  
</td><td>lprintd</td><td>Delete a print job</td></tr><tr><td>  
</td><td>lprintq</td><td>List the print queue</td></tr><tr><td>  
</td><td>[lprm](https://ss64.com/bash/lprm.html)</td><td>Remove jobs from the print queue</td></tr><tr><td>  
</td><td>[lsattr](https://ss64.com/bash/lsattr.html)</td><td>List file attributes on a Linux second extended file system</td></tr><tr><td>  
</td><td>[lsblk](https://ss64.com/bash/lsblk.html)</td><td>List block devices</td></tr><tr><td>  
</td><td>[ls](https://ss64.com/bash/ls.html)</td><td>List information about file(s)</td></tr><tr><td>  
</td><td>[lsof](https://ss64.com/bash/lsof.html)</td><td>List open files</td></tr><tr><td>  
</td><td>[lspci](https://ss64.com/bash/lspci.html)</td><td>List all PCI devices</td></tr><tr><td><a id="bkmrk--11"></a>M</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>make</td><td>Recompile a group of programs</td></tr><tr><td>  
</td><td>[man](https://ss64.com/bash/man.html)</td><td>Help manual</td></tr><tr><td>  
</td><td>[mapfile](https://ss64.com/bash/mapfile.html)</td><td>Read lines from standard input into an indexed array variable •</td></tr><tr><td>  
</td><td>[mkdir](https://ss64.com/bash/mkdir.html)</td><td>Create new folder(s)</td></tr><tr><td>  
</td><td>[mkfifo](https://ss64.com/bash/mkfifo.html)</td><td>Make FIFOs (named pipes)</td></tr><tr><td>  
</td><td>[mkfile](https://ss64.com/bash/mkfile.html)</td><td>Make a file</td></tr><tr><td>  
</td><td>mkisofs</td><td>Create a hybrid ISO9660/JOLIET/HFS filesystem</td></tr><tr><td>  
</td><td>[mknod](https://ss64.com/bash/mknod.html)</td><td>Make block or character special files</td></tr><tr><td>  
</td><td>[mktemp](https://ss64.com/bash/mktemp.html)</td><td>Make a temporary file</td></tr><tr><td>  
</td><td>[more](https://ss64.com/bash/more.html)</td><td>Display output one screen at a time</td></tr><tr><td>  
</td><td>[most](https://ss64.com/bash/most.html)</td><td>Browse or page through a text file</td></tr><tr><td>  
</td><td>[mount](https://ss64.com/bash/mount.html)</td><td>Mount a file system</td></tr><tr><td>  
</td><td>[mtools](https://ss64.com/bash/mtools.html)</td><td>Manipulate MS-DOS files</td></tr><tr><td>  
</td><td>[mtr](https://ss64.com/bash/mtr.html)</td><td>Network diagnostics (traceroute/ping)</td></tr><tr><td>  
</td><td>[mv](https://ss64.com/bash/mv.html)</td><td>Move or rename files or directories</td></tr><tr><td>  
</td><td>[mmv](https://ss64.com/bash/mmv.html)</td><td>Mass Move and rename (files)</td></tr><tr><td><a id="bkmrk--12"></a>N</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[nc](https://ss64.com/bash/nc.html)</td><td>Netcat, read and write data across networks</td></tr><tr><td>  
</td><td>[netstat](https://ss64.com/bash/netstat.html)</td><td>Networking connections/stats</td></tr><tr><td>  
</td><td>[nft](https://ss64.com/bash/nft.html)</td><td>nftables for packet filtering and classification</td></tr><tr><td>  
</td><td>[nice](https://ss64.com/bash/nice.html)</td><td>Set the priority of a command or job</td></tr><tr><td>  
</td><td>[nl](https://ss64.com/bash/nl.html)</td><td>Number lines and write files</td></tr><tr><td>  
</td><td>[nohup](https://ss64.com/bash/nohup.html)</td><td>Run a command immune to hangups</td></tr><tr><td>  
</td><td>[notify-send](https://ss64.com/bash/notify-send.html)</td><td>Send desktop notifications</td></tr><tr><td>  
</td><td>[nslookup](https://ss64.com/bash/nslookup.html)</td><td>Query Internet name servers interactively</td></tr><tr><td><a id="bkmrk--13"></a>O</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[open](https://ss64.com/bash/open.html)</td><td>Open a file in its default application</td></tr><tr><td>  
</td><td>[op](https://ss64.com/bash/op.html)</td><td>Operator access</td></tr><tr><td><a id="bkmrk--14"></a>P</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[passwd](https://ss64.com/bash/passwd.html)</td><td>Modify a user password</td></tr><tr><td>  
</td><td>[paste](https://ss64.com/bash/paste.html)</td><td>Merge lines of files</td></tr><tr><td>  
</td><td>pathchk</td><td>Check file name portability</td></tr><tr><td>  
</td><td>[Perf](https://ss64.com/bash/perf.html)</td><td>Performance analysis tools for Linux</td></tr><tr><td>  
</td><td>[ping](https://ss64.com/bash/ping.html)</td><td>Test a network connection</td></tr><tr><td>  
</td><td>[pgrep](https://ss64.com/bash/pkill.html)</td><td>List processes by name</td></tr><tr><td>  
</td><td>[pkill](https://ss64.com/bash/pkill.html)</td><td>Kill processes by name</td></tr><tr><td>  
</td><td>[popd](https://ss64.com/bash/popd.html)</td><td>Restore the previous value of the current directory</td></tr><tr><td>  
</td><td>[pr](https://ss64.com/bash/pr.html)</td><td>Prepare files for printing</td></tr><tr><td>  
</td><td>printcap</td><td>Printer capability database</td></tr><tr><td>  
</td><td>[printenv](https://ss64.com/bash/printenv.html)</td><td>Print environment variables</td></tr><tr><td>  
</td><td>[printf](https://ss64.com/bash/printf.html)</td><td>Format and print data •</td></tr><tr><td>  
</td><td>[ps](https://ss64.com/bash/ps.html)</td><td>Process status</td></tr><tr><td>  
</td><td>[pushd](https://ss64.com/bash/pushd.html)</td><td>Save and then change the current directory</td></tr><tr><td>  
</td><td>[pv](https://ss64.com/bash/pv.html)</td><td>Monitor the progress of data through a pipe</td></tr><tr><td>  
</td><td>[pwd](https://ss64.com/bash/pwd.html)</td><td>Print Working Directory</td></tr><tr><td><a id="bkmrk--15"></a>Q</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[quota](https://ss64.com/bash/quota.html)</td><td>Display disk usage and limits</td></tr><tr><td>  
</td><td>[quotacheck](https://ss64.com/bash/quotacheck.html)</td><td>Scan a file system for disk usage</td></tr><tr><td><a id="bkmrk--16"></a>R</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[ram](https://ss64.com/bash/ram.html)</td><td>ram disk device</td></tr><tr><td>  
</td><td>[rar](https://ss64.com/bash/rar.html)</td><td>Archive files with compression</td></tr><tr><td>  
</td><td>[rcp](https://ss64.com/bash/rcp.html)</td><td>Copy files between two machines</td></tr><tr><td>  
</td><td>[read](https://ss64.com/bash/read.html)</td><td>Read a line from standard input •</td></tr><tr><td>  
</td><td>[readarray](https://ss64.com/bash/mapfile.html)</td><td>Read from stdin into an array variable •</td></tr><tr><td>  
</td><td>[readonly](https://ss64.com/bash/readonly.html)</td><td>Mark variables/functions as readonly</td></tr><tr><td>  
</td><td>reboot</td><td>Reboot the system</td></tr><tr><td>  
</td><td>[rename](https://ss64.com/bash/rename.html)</td><td>Rename files</td></tr><tr><td>  
</td><td>renice</td><td>Alter priority of running processes</td></tr><tr><td>  
</td><td>remsync</td><td>Synchronize remote files via email</td></tr><tr><td>  
</td><td>[return](https://ss64.com/bash/return.html)</td><td>Exit a shell function</td></tr><tr><td>  
</td><td>[rev](https://ss64.com/bash/rev.html)</td><td>Reverse lines of a file</td></tr><tr><td>  
</td><td>[rm](https://ss64.com/bash/rm.html)</td><td>Remove files</td></tr><tr><td>  
</td><td>[rmdir](https://ss64.com/bash/rmdir.html)</td><td>Remove folder(s)</td></tr><tr><td>  
</td><td>[rsync](https://ss64.com/bash/rsync.html)</td><td>Remote file copy (Synchronize file trees)</td></tr><tr><td><a id="bkmrk--17"></a>S</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[screen](https://ss64.com/bash/screen.html)</td><td>Multiplex terminal, run remote shells via ssh</td></tr><tr><td>  
</td><td>[scp](https://ss64.com/bash/scp.html)</td><td>Secure copy (remote file copy)</td></tr><tr><td>  
</td><td>[sdiff](https://ss64.com/bash/sdiff.html)</td><td>Merge two files interactively</td></tr><tr><td>  
</td><td>[sed](https://ss64.com/bash/sed.html)</td><td>Stream Editor</td></tr><tr><td>  
</td><td>[select](https://ss64.com/bash/select.html)</td><td>Accept user choices via keyboard input</td></tr><tr><td>  
</td><td>[seq](https://ss64.com/bash/seq.html)</td><td>Print numeric sequences</td></tr><tr><td>  
</td><td>[set](https://ss64.com/bash/set.html)</td><td>Manipulate shell variables and functions</td></tr><tr><td>  
</td><td>[setfacl](https://ss64.com/bash/setfacl.html)</td><td>Set file access control lists.</td></tr><tr><td>  
</td><td>sftp</td><td>Secure File Transfer Program</td></tr><tr><td>  
</td><td>[sha256sum](https://ss64.com/bash/sha256sum.html)</td><td>Compute and check SHA256 (256-bit) checksums</td></tr><tr><td>  
</td><td>[shift](https://ss64.com/bash/shift.html)</td><td>Shift positional parameters</td></tr><tr><td>  
</td><td>[shopt](https://ss64.com/bash/shopt.html)</td><td>Shell Options</td></tr><tr><td>  
</td><td>[shuf](https://ss64.com/bash/shuf.html)</td><td>Generate random permutations</td></tr><tr><td>  
</td><td>[shutdown](https://ss64.com/bash/shutdown.html)</td><td>Shutdown or restart linux</td></tr><tr><td>  
</td><td>[sleep](https://ss64.com/bash/sleep.html)</td><td>Delay for a specified time</td></tr><tr><td>  
</td><td>[slocate](https://ss64.com/bash/slocate.html)</td><td>Find files</td></tr><tr><td>  
</td><td>[sort](https://ss64.com/bash/sort.html)</td><td>Sort text files</td></tr><tr><td>  
</td><td>[source](https://ss64.com/bash/source.html)</td><td>Run commands from a file '.' •</td></tr><tr><td>  
</td><td>[split](https://ss64.com/bash/split.html)</td><td>Split a file into fixed-size pieces</td></tr><tr><td>  
</td><td>[ss](https://ss64.com/bash/ss.html)</td><td>Socket Statistics</td></tr><tr><td>  
</td><td>[ssh](https://ss64.com/bash/ssh.html)</td><td>Secure Shell client (remote login program)</td></tr><tr><td>  
</td><td>[stat](https://ss64.com/bash/stat.html)</td><td>Display file or file system status</td></tr><tr><td>  
</td><td>[strace](https://ss64.com/bash/strace.html)</td><td>Trace system calls and signals</td></tr><tr><td>  
</td><td>[su](https://ss64.com/bash/su.html)</td><td>Substitute user identity</td></tr><tr><td>  
</td><td>[sudo](https://ss64.com/bash/sudo.html)</td><td>Execute a command as another user</td></tr><tr><td>  
</td><td>[sum](https://ss64.com/bash/sum.html)</td><td>Print a checksum for a file</td></tr><tr><td>  
</td><td>[suspend](https://ss64.com/bash/suspend.html)</td><td>Suspend execution of this shell •</td></tr><tr><td>  
</td><td>[sync](https://ss64.com/bash/sync.html)</td><td>Synchronize data on disk with memory</td></tr><tr><td><a id="bkmrk--18"></a>T</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[tail](https://ss64.com/bash/tail.html)</td><td>Output the last part of a file</td></tr><tr><td>  
</td><td>[tar](https://ss64.com/bash/tar.html)</td><td>Store, list or extract files in an archive</td></tr><tr><td>  
</td><td>[tee](https://ss64.com/bash/tee.html)</td><td>Redirect output to multiple files</td></tr><tr><td>  
</td><td>[test](https://ss64.com/bash/test.html)</td><td>Evaluate a conditional expression</td></tr><tr><td>  
</td><td>[time](https://ss64.com/bash/time.html)</td><td>Measure Program running time</td></tr><tr><td>  
</td><td>[timeout](https://ss64.com/bash/timeout.html)</td><td>Run a command with a time limit</td></tr><tr><td>  
</td><td>[times](https://ss64.com/bash/times.html)</td><td>User and system times</td></tr><tr><td>  
</td><td>[tmux](https://ss64.com/bash/tmux.html)</td><td>Terminal multiplexer</td></tr><tr><td>  
</td><td>[touch](https://ss64.com/bash/touch.html)</td><td>Change file timestamps</td></tr><tr><td>  
</td><td>[top](https://ss64.com/bash/top.html)</td><td>List processes running on the system</td></tr><tr><td>  
</td><td>[tput](https://ss64.com/bash/tput.html)</td><td>Set terminal-dependent capabilities, color, position</td></tr><tr><td>  
</td><td>[traceroute](https://ss64.com/bash/traceroute.html)</td><td>Trace Route to Host</td></tr><tr><td>  
</td><td>[trap](https://ss64.com/bash/trap.html)</td><td>Execute a command when the shell receives a signal •</td></tr><tr><td>  
</td><td>[tr](https://ss64.com/bash/tr.html)</td><td>Translate, squeeze, and/or delete characters</td></tr><tr><td>  
</td><td>[true](https://ss64.com/bash/true.html)</td><td>Do nothing, successfully</td></tr><tr><td>  
</td><td>[tsort](https://ss64.com/bash/tsort.html)</td><td>Topological sort</td></tr><tr><td>  
</td><td>[tty](https://ss64.com/bash/tty.html)</td><td>Print filename of terminal on stdin</td></tr><tr><td>  
</td><td>[type](https://ss64.com/bash/type.html)</td><td>Describe a command •</td></tr><tr><td><a id="bkmrk--19"></a>U</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[ulimit](https://ss64.com/bash/ulimit.html)</td><td>Limit user resources •</td></tr><tr><td>  
</td><td>[umask](https://ss64.com/bash/umask.html)</td><td>Users file creation mask</td></tr><tr><td>  
</td><td>umount</td><td>Unmount a device</td></tr><tr><td>  
</td><td>[unalias](https://ss64.com/bash/alias.html)</td><td>Remove an alias •</td></tr><tr><td>  
</td><td>[uname](https://ss64.com/bash/uname.html)</td><td>Print system information</td></tr><tr><td>  
</td><td>[unexpand](https://ss64.com/bash/unexpand.html)</td><td>Convert spaces to tabs</td></tr><tr><td>  
</td><td>[uniq](https://ss64.com/bash/uniq.html)</td><td>Uniquify files</td></tr><tr><td>  
</td><td>[units](https://ss64.com/bash/units.html)</td><td>Convert units from one scale to another</td></tr><tr><td>  
</td><td>[unix2dos](https://ss64.com/bash/unix2dos.html)</td><td>UNIX to Windows or MAC text file format converter</td></tr><tr><td>  
</td><td>[unrar](https://ss64.com/bash/unrar.html)</td><td>Extract files from a rar archive</td></tr><tr><td>  
</td><td>[unset](https://ss64.com/bash/unset.html)</td><td>Remove variable or function names</td></tr><tr><td>  
</td><td>[unshar](https://ss64.com/bash/unshar.html)</td><td>Unpack shell archive scripts</td></tr><tr><td>  
</td><td>[until](https://ss64.com/bash/until.html)</td><td>Execute commands (until error)</td></tr><tr><td>  
</td><td>uptime</td><td>Show uptime</td></tr><tr><td>  
</td><td>[useradd](https://ss64.com/bash/useradd.html)</td><td>Create new user account</td></tr><tr><td>  
</td><td>[userdel](https://ss64.com/bash/userdel.html)</td><td>Delete a user account</td></tr><tr><td>  
</td><td>[usermod](https://ss64.com/bash/usermod.html)</td><td>Modify user account</td></tr><tr><td>  
</td><td>[users](https://ss64.com/bash/users.html)</td><td>List users currently logged in</td></tr><tr><td>  
</td><td>[uuencode](https://ss64.com/bash/uuencode.html)</td><td>Encode a binary file</td></tr><tr><td>  
</td><td>[uudecode](https://ss64.com/bash/uuencode.html)</td><td>Decode a file created by uuencode</td></tr><tr><td><a id="bkmrk--20"></a>V</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>v</td><td>Verbosely list directory contents ('ls -l -b')</td></tr><tr><td>  
</td><td>vdir</td><td>Verbosely list directory contents ('ls -l -b')</td></tr><tr><td>  
</td><td>[vi](https://ss64.com/vi.html)</td><td>Text Editor</td></tr><tr><td>  
</td><td>[vmstat](https://ss64.com/bash/vmstat.html)</td><td>Report virtual memory statistics</td></tr><tr><td><a id="bkmrk--21"></a>W</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[w](https://ss64.com/bash/w.html)</td><td>Show who is logged on and what they are doing</td></tr><tr><td>  
</td><td>[wait](https://ss64.com/bash/wait.html)</td><td>Wait for a process to complete •</td></tr><tr><td>  
</td><td>[watch](https://ss64.com/bash/watch.html)</td><td>Execute/display a program periodically</td></tr><tr><td>  
</td><td>[wc](https://ss64.com/bash/wc.html)</td><td>Print byte, word, and line counts</td></tr><tr><td>  
</td><td>[whereis](https://ss64.com/bash/whereis.html)</td><td>Search the user's $path, man pages and source files for a program</td></tr><tr><td>  
</td><td>[which](https://ss64.com/bash/which.html)</td><td>Search the user's $path for a program file</td></tr><tr><td>  
</td><td>[while](https://ss64.com/bash/while.html)</td><td>Execute commands</td></tr><tr><td>  
</td><td>[who](https://ss64.com/bash/who.html)</td><td>Print all usernames currently logged in</td></tr><tr><td>  
</td><td>[whoami](https://ss64.com/bash/whoami.html)</td><td>Print the current user id and name ('id -un')</td></tr><tr><td>  
</td><td>wget</td><td>Retrieve web pages or files via HTTP, HTTPS or FTP</td></tr><tr><td>  
</td><td>[write](https://ss64.com/bash/write.html)</td><td>Send a message to another user</td></tr><tr><td>X</td><td>  
</td><td>  
</td></tr><tr><td>  
</td><td>[xargs](https://ss64.com/bash/xargs.html)</td><td>Execute utility, passing constructed argument list(s)</td></tr><tr><td>  
</td><td>[xdg-open](https://ss64.com/bash/xdg-open.html)</td><td>Open a file or URL in the user's preferred application.</td></tr><tr><td>  
</td><td>[xxd](https://ss64.com/bash/xxd.html)</td><td>Make a hexdump or do the reverse</td></tr><tr><td>  
</td><td>[xz](https://ss64.com/bash/xz.html)</td><td>Compress or decompress .xz and .lzma files</td></tr><tr><td>  
</td><td>[yes](https://ss64.com/bash/yes.html)</td><td>Print a string until interrupted</td></tr><tr><td>  
</td><td>[zip](https://ss64.com/bash/zip.html)</td><td>Package and compress (archive) files</td></tr><tr><td>  
</td><td>[.](https://ss64.com/bash/source.html)</td><td>[Run](https://ss64.com/bash/source.html) a command script in the current shell</td></tr><tr><td>  
</td><td>[!!](https://ss64.com/bash/bang.html)</td><td>Run the [last](https://ss64.com/bash/bang.html) command again</td></tr><tr><td>  
</td><td>[\###](https://ss64.com/bash/rem.html)</td><td>Comment / [Rem](https://ss64.com/bash/rem.html)ark</td></tr></tbody></table>

Sourced (and copied directly) from ss64.com

# UnZip and UnCompress

#### xz-utils:

You will need xz-utils if you dont have it already. If not, You have to install xz-utils package first:

```c++
sudo apt-get install xz-utils
```

You can use unxz command to extract .xz files:

```
unxz file.xz
```

or using with --decompress option of xz:

```
xz --decompress file.xz
```

---

#### 7 Zip

You will need 7zipif you dont have it already. If not, You have to install xz-utils package first:

```bash
sudo apt install p7zip
```

Then, uncompress using the `-d` command:

```bash
p7zip -d something.7z
```

# How to check IP address from command line | Internal and External

#### Check your Internal IP address

To check you current machines addres: "ip add" or "ip addr" or;

```bash
ip address
```

#### Check your external IP address

First make sure that the curl command is installed. If not, do this

```bash
sudo apt install curl
```

By using curl, check the external address by doing this;

```bash
curl -w "\n" -s https://api.ipify.org
```

That should give an output of your external IP address.

# UFW

Allow ports

```bash
sudo ufw allow 22
```

remove ports

```bash
sudo ufw delete allow 22
```

# How to clean log files in Linux

Fisrt, See the logs that are in the logs area of /var

```bash
du -h /var/log/
```

The du command prints the estimated disk space usage of each file and directory for the path that you specified.  
The -h argument causes the command to print the information in a human-readable format.

https://linuxhandbook.com/empty-file-linux/

https://support.hostway.com/hc/en-us/articles/360001972270-How-to-clean-log-files-in-Linux