Linux
If you’re a Developer or Engineer, mastering Linux is more than just a skill—it’s a superpower! I’ll admit, when I started my career, I didn’t even know how to exit Vim (yes, I was that person!). Even now, Vim as a code editor still intimidates me sometimes.
That said, for the past 5 years, I’ve used Linux as my primary OS. While I wouldn’t call myself a “power user,” I rely on it every single day. From navigating the terminal to automating tasks, Linux has become an indispensable part of my workflow.
In this post, I’m sharing some of the day-to-day Linux commands that I use regularly. These are the commands that help me stay productive, efficient, and, occasionally, even feel like a tech wizard. I’ll keep updating this blog as I learn new ones.
Let’s dive in!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
## list down all file and folder with recent order at end
ls -laShtr
## show like tree-like format
# -L level
# -d directory-only
# --gitignore
# -I ignore
tree -L 2 .
## switching directories
cd
## moving files from source to target-destination
mv source target
## copy file
cp source_file destination_folder
## remove file (not able to recover)
rm file
rm -rf non_empty_folder
## System running time
# -p --pretty
# -s --since
uptime -s
## display CPU architecture info
lscpu
## system info
# --Full -F
# --memory -m
# --partitions-full -p
# --repos -r
# -z
# -x
inxi -Fxpmrz
## get file access control lists
getfactl path_to_file.wtf
## change file mode
chmod
## datetime
date +"%H-%M-%S::%T"
## Display amount of free and used memory in the system
# --mebi -m
# --lohi (show low and high memory stats)
# --total -t
# --human -h
free -mlth
## Print network connections, routing table, ..
# -t --tcp
# -u --udp
# -l --listening
# -a --all
# -n --numeric (show numerical address)
# -p program (show PID and name of program for each socket)
netstat -tulanp
## file sys space usage
df -H
## estimate file space usage
du -ch
## background ( running job by background using "&" )
bg
## foreground
fg
## list jobs
jobs
## print all env
printenv
## system's host name
hostname
## info script
neofetch
## list of commands used
history
## archieving utility
# --create
# -f --file
# -z --compress
# -v --verbose
# -x --extract
tar -xvzf
## print line that match pattern
# -i --ignore-case
grep
## word count
# -l --lines
# -w --words
wc
## number lines of file
nl
# CMD json processor
jq
## show file
cat /proc/cpuinfo
more
less
cut -d , -f 1 tips.csv # -d --delimeter -f fields
## OpenSSH secure file copy
scp
## a fast, versatile, remote (and local) file-copying tool (similiar to SCP but faster)
# -v verbose
# -a archive mode;
# -z compresses the transmitted data
rsync
## OpenSSH remote login client
# -i identity-file for pem file while connecting EC2
ssh username@IpAddress
## request url
ping
## reterives public IP
curl ifconfig.me
## speed test
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
## find folder with pattern
# -n name
# -o optional
# trash it
find . -type d \( -name '__pycache__' -o -name 'logs' -o -name 'outputs' \) -exec gio trash {} +
## Monitoring Tools
htop # interactive process viewer
btm # Yet another cross-platform graphical process/system monitor
nvitop -m # monitor GPU
ctop # container
docker stats
lazydocker # monitor service and compose
append following to .bashrc file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# SHOW GIT BRANCH NAME in Terminal
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
# GIT ALias
if [ -x /usr/bin/git ]; then
alias gl='git log --oneline --graph --all'
alias gs='git status'
fi
# Instead of rm command: (move to trash instead os.remove)
if [ -x /usr/bin/gio ]; then
alias del='gio trash'
fi
# TMUX
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
tmux attach-session -t default || tmux new-session -s default
fi
As I said Linux is vast, and there are numerous resources to learn from. One excellent blog I came across is linked below: