3 minutes
Top Linux Commands
New to Linux or support hundreds of servers? Here are my top-10 favorite linux commands/one liners.
df -h
- defacto for seeing how much drive space is per file system, used, available, percentage, and where it is mounted.➜ ~ df -h Filesystem Size Used Avail Use% Mounted on udev 6.8G 0 6.8G 0% /dev tmpfs 1.4G 2.2M 1.4G 1% /run /dev/mapper/data-root 450G 157G 271G 37% / tmpfs 6.9G 173M 6.7G 3% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 6.9G 0 6.9G 0% /sys/fs/cgroup /dev/nvme0n1p2 4.0G 2.1G 2.0G 52% /recovery /dev/nvme0n1p1 498M 187M 311M 38% /boot/efi tmpfs 1.4G 20K 1.4G 1% /run/user/110 tmpfs 1.4G 96K 1.4G 1% /run/user/1000 /dev/sda1 916G 45G 825G 6% /media/bryanlurer/1tb_ssd
sysinfo
- Well this one is a script for me.. GITHUB LINK HIER. I just typesysinfo
and it gives me the details I need.➜ ~ sysinfo Username: bryanlurer Hostname: a300 External IP: 123.456.789.12 Weather: San Miguel, Philippines: ⛈ +32°C Load: 1.34 0.51 0.42 1/1397 21739
curl v2.wttr.in
- Weather in your terminal! Lots of formatting options for one liner, such as in the sysinfo command.apti
- Ubuntu/Debian - An alias for the following:sudo apt update -y ; sudo apt install -y
yumi
- RHEL/CentOS/Amazon Linux - An alias for the following:sudo yum update -y ; sudo yum install -y
wavemon
- If you have wifi it will show signal, link quality, signal over time, which frequency you are using. A fantastic CLI tool for Linux.ssh user@host(name or IP)
- connects to host as userssh -p <port> user@host(name or IP)
- connects to host on specified port as specified userssh-copy-id user@host
- adds your ssh key to host for passwordless login - should be standard!passwd
- Change your passworddate
- Shows the current date and time.[ec2-user@ip-172-26-6-216 ~]$ date Sun Jul 19 02:15:21 UTC 2020
uptime
- Shows system uptime and load average.[ec2-user@ip-172-26-6-216 ~]$ uptime 02:14:34 up 2 min, 2 users, load average: 0.04, 0.04, 0.01
w
- Displays who is logged in, duration, and ip[ec2-user@ip-172-26-6-216 ~]$ w 02:13:26 up 0 min, 2 users, load average: 0.15, 0.06, 0.02 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ec2-user pts/0 vps-722c62c5.vps 02:12 30.00s 0.00s 0.00s -bash ec2-user pts/1 1.2.3.4 02:13 1.00s 0.00s 0.00s w
uname -a
- Shows kernel information[ec2-user@ip-172-26-6-216 ~]$ uname -a Linux ip-172-26-6-216 4.14.181-108.257.amzn1.x86_64 #1 SMP Wed May 27 02:43:03 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
man {command}
- Shows the manual for specified command.[ec2-user@ip-172-26-6-216 ~]$ man ls ... LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
du -h {file/dir}
- Shows the disk usage of the files and directories.[ec2-user@ip-172-26-6-216 ~]$ du -h 8.0K ./.ssh 668M .
ps -u {user}
- lists your processes[ec2-user@ip-172-26-6-216 ~]$ ps -u ec2-user PID TTY TIME CMD 2800 ? 00:00:00 sshd 2801 pts/0 00:00:00 bash 2830 ? 00:00:00 sshd 2831 pts/1 00:00:00 bash 2887 pts/1 00:00:00 ps
curl
- Transfers data.[ec2-user@ip-172-26-6-216 ~]$ curl -s ifconfig.me 52.52.52.52
wc -l
- Counts lines in a file:[ec2-user@ip-172-26-6-216 ~]$ wc -l important_data.txt 71721955 important_data.txt
ping {host/ip}
- Pings host and outputs results. Will continue forever unless-c {#}
is provided.[ec2-user@ip-172-26-6-216 ~]$ ping 1.1.1.1 -c 5 PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data. 64 bytes from 1.1.1.1: icmp_seq=1 ttl=49 time=1.18 ms 64 bytes from 1.1.1.1: icmp_seq=2 ttl=49 time=1.23 ms 64 bytes from 1.1.1.1: icmp_seq=3 ttl=49 time=1.23 ms 64 bytes from 1.1.1.1: icmp_seq=4 ttl=49 time=1.21 ms 64 bytes from 1.1.1.1: icmp_seq=5 ttl=49 time=1.23 ms --- 1.1.1.1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4005ms rtt min/avg/max/mdev = 1.183/1.219/1.234/0.036 ms
And that is it for now. What commands are your favorites and most useful?
639 Words
2020-07-10 01:20 +0000