Files
knowledge/categories/devops/linux.md
T
2018-10-29 13:56:54 +11:00

1.7 KiB

Linux

Useful commands and tips

ssh

Do not use default 22 port

ssh user@ip -p 22222

IP table

Cron job

PS

ps aux | grep 'ruby'

List process, using grep to filter processes

tail

Tailing texts from file in realtime

tail -f a.log

f means following, auto append texts to console

nohup

Simply running application in background

df

df -h

Show disk usage and left, h means show in human readable way. Normally by MB/GB.

free

              total        used        free      shared  buff/cache   available
Mem:        3960624      416720      270024       22252     3273880     3264060
Swap:       4104188      109688     3994500

Show memory usage and

Watch

watch kubectl get pods

Continuous running the commands, watching the changes. By default it refresh the result every 2s.

Change timezone

TZ=Asia/Shanghai;
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime

Check release

cat /etc/*-release

Debian check system version

cat /etc/issue

cat /etc/debian_version

htop

like top, but more

mosh

auto reconnect ssh

show last something time

last shutdown
last reboot

Count files in current folder

find . -type f | wc -l

Check if a port is open

Used Netcat

if ! nc -z localhost 5672; then
sleep 3;
fi

scp copy files between host

Copy files from remote server

scp your_username@remotehost.edu:foobar.txt /local/dir

Copy local files to remote server

scp /path/to/local/file user@server:/path/to/remote/file

Package manager