Linux Misc
(updated: )
Linux distribution info
cat /etc/*-release
lsb_release -a
uname -mrs
Check ram info
sudo dmidecode -t memory
sudo lshw -short -C memory
Shell
File operators
| operator |
description |
| -e |
file exists |
| -a |
same as -e, deprecated |
| -f |
file is a regular file (not a directory or device file) |
| -s |
file is not zero size |
| -d |
file is a directory |
| -b |
file is a block device |
| -c |
file is a character device |
| -p |
file is a pipe |
| -h |
file is a symbolic link |
| -L |
file is a symbolic link |
| -S |
file is a socket |
| -t |
file is associated with a terminal device |
| -r |
file has read permission |
| -w |
file has write permission |
| -x |
file has execution permission |
| -O |
you are owner of file |
| -G |
group-id of file same as yours |
| -N |
file modified since it was last read |
| f1 -nt f2 |
file f1 is newer than f2 |
| f1 -ot f2 |
file f1 is older than f2 |
| f1 -ef f2 |
files f1 and f2 are hard links to the same file |
String operators
| operator |
description |
| -n |
the length is nonzero |
| -z |
the length is zero |
| s1 = s2 |
two strings are identical |
| s1 != s2 |
two strings are not identical |
| s1 |
s1 is not null |
Number operators
| operator |
description |
| -eq |
equal |
| -ne |
not equal |
| -gt |
greater than |
| -ge |
greater or equal |
| -lt |
less than |
| -le |
less or equal |
Script environment
set -x Print commands and their arguments as they are executed.
set +x Disabling it.
Open files
List File Opened By a PID
List File Descriptors in Kernel Memory
Network Usage
1
| sudo apt-get install speedometer
|
Password
random password
nginx basic auth
1 2 3 4 5
| location /protected { autoindex on; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/conf.d/.htpasswd; }
|
1
| echo "user:$(openssl passwd -1 password)\n" >> .htpasswd
|