General Linux Commands | In terminal
- Check operating system
cat/etc/*rel*
- Check system info
- CPU
cat /proc/cpuinfo
- Memory
cat /proc/meminfo
- CPU
- 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/
- directory / folder
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 directoryapt-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
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]]
No Comments