Skip to main content

New Page

  • Check operating system
    cat/etc/*rel*
  • 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 system info
            - CPU
                - cat /proc/cpuinfo
            - Memory
                - cat /proc/meminfo

- Set Timezone
    - https://devconnected.com/how-to-set-date-and-time-on-linux/
    
Run cheat-sheet
```
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.
```

#### Check file size: 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
-   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 


## NGINX
    `systemctl start nginx`
    `systemctl stop nginx`
    `systemctl restart nginx`
    `systemctl status nginx`

## Docker:
- Do you have docker?
        `docker -v`
- Install Docker
        `apt install docker`
- Do you have docker-compose?
        `docker-compose -v`
- Docker in Linux Commands
    `docker images`
    `docker ps -a`
    `docker ps`
    `docker`
- Go into a Container
    - `sudo docker exec -it containername bash`

Run docker from different directory:
```
sudo docker-compose -f /directory/to/file/docker-compose.yml up -d
```

Minimize: Go back to terminal withouse getting out of your doc
`Ctrl=Z`
To go back  `fg` 

/usr/local/searxng/searx/static/themes/simple/img/searxng.png
```

###### Run docker-compose from another directory
docker-compose -f /tmp/myproject/docker-compose.yml up -d

## Map Network drive
First, Need to make sure you have [[Samba]] and smbclient and, Cifs-utils. Install them

1: create a mount point (if you haven't already)
```
sudo mkdir /directry to mount
```

2: Mount the volume
```
sudo mount -t cifs //[addressofshare]/[folderofshare] -o usernam=ofshare /[localdirectorytomountto] 

Exaple:
sudo mount -t cifs //192.168.3.456/smbshare -o username=bob /mnt/remote
```
Then when asked for password, type in password of the share folder, not your local machine. 

## Computer susbend / wakeup automatically 
> sudo rtcwake -m [type of suspend] -s [number of seconds]

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
The **-s** 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.

The **-t** 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.

The **-l** 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]]