LINUX Commands
hostname
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# uname -n
DESKTOP-CL9FNGA
root@DESKTOP-CL9FNGA:~#
long listing
root@DESKTOP-CL9FNGA:~# ls -l
total 65972
drwxr-xr-x 3 root root 4096 Apr 8 03:13 GIT
drwxr-xr-x 3 root root 4096 Dec 13 19:24 aws
-rw-r--r-- 1 root root 67517785 Dec 15 17:33 awscliv2.zip
-rwx------ 1 root root 11903 Dec 14 17:09 get_helm.sh
drwxr-xr-x 3 root root 4096 Apr 8 03:12 kong-routing-stack
drwx------ 3 root root 4096 Dec 27 06:01 snap
drwxr-xr-x 5 root root 4096 Apr 8 03:19 venv
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# ls
GIT aws awscliv2.zip get_helm.sh kong-routing-stack snap venv
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:a7:12:bb:97 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.28.76.177 netmask 255.255.240.0 broadcast 172.28.79.255
inet6 fe80::215:5dff:fe9d:b727 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:9d:b7:27 txqueuelen 1000 (Ethernet)
RX packets 33008 bytes 48091228 (48.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3339 bytes 245518 (245.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@DESKTOP-CL9FNGA:~#
grep command
root@DESKTOP-CL9FNGA:~# ls -l |grep -i git
drwxr-xr-x 3 root root 4096 Apr 8 03:13 GIT
root@DESKTOP-CL9FNGA:~#
listing
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# ls -la
total 66076
drwx------ 17 root root 4096 Apr 28 05:44 .
drwxr-xr-x 22 root root 4096 May 5 05:26 ..
drwxr-xr-x 3 root root 4096 Nov 30 07:30 .ansible
drwxr-xr-x 2 anantgsaraf123 anantgsaraf123 4096 Dec 23 17:49 .aws
drwxr-xr-x 5 root root 4096 Apr 30 07:33 .azure
-rw------- 1 root root 16596 Apr 30 07:43 .bash_history
-rw-r--r-- 1 root root 3164 Nov 30 11:16 .bashrc
drwx------ 5 root root 4096 Apr 28 05:44 .cache
drwx------ 3 root root 4096 Apr 8 04:35 .docker
-rw-r--r-- 1 root root 277 Dec 14 19:06 .gitconfig
drwx------ 2 root root 4096 Nov 30 07:19 .gnupg
drwxr-xr-x 3 root root 4096 Dec 27 06:06 .kube
drwx------ 3 root root 4096 Nov 23 07:15 .launchpadlib
-rw------- 1 root root 20 Apr 8 03:35 .lesshst
drwxr-xr-x 3 root root 4096 Dec 5 06:42 .local
-rw-r--r-- 1 root root 0 May 5 05:30 .motd_shown
-rw-r--r-- 1 root root 161 Apr 22 2024 .profile
drwx------ 2 root root 4096 Apr 30 06:46 .ssh
-rw------- 1 root root 28 Dec 5 18:03 .vault-token
-rw------- 1 root root 12094 Feb 24 18:42 .viminfo
-rw-r--r-- 1 root root 181 Dec 15 07:00 .wget-hsts
drwxr-xr-x 3 root root 4096 Apr 8 03:13 GIT
drwxr-xr-x 3 root root 4096 Dec 13 19:24 aws
-rw-r--r-- 1 root root 67517785 Dec 15 17:33 awscliv2.zip
-rwx------ 1 root root 11903 Dec 14 17:09 get_helm.sh
drwxr-xr-x 3 root root 4096 Apr 8 03:12 kong-routing-stack
drwx------ 3 root root 4096 Dec 27 06:01 snap
drwxr-xr-x 5 root root 4096 Apr 8 03:19 venv
root@DESKTOP-CL9FNGA:~#
how to get more information about any command
man ls
mkdir command
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp# mkdir test
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp# ls -l
total 24
srwxrwxrwx 1 root root 0 May 5 05:27 dbus-51oQ3Sviii
drwx------ 2 root root 4096 May 5 05:26 snap-private-tmp
drwx------ 3 root root 4096 May 5 05:26 systemd-private-6bf581919ed34ce09da363bd201bc3b9-systemd-logind.service-iXPOHz
drwx------ 3 root root 4096 May 5 05:26 systemd-private-6bf581919ed34ce09da363bd201bc3b9-systemd-resolved.service-iR1Eyr
drwx------ 3 root root 4096 May 5 05:26 systemd-private-6bf581919ed34ce09da363bd201bc3b9-systemd-timesyncd.service-IGllZ5
drwx------ 3 root root 4096 May 5 05:26 systemd-private-6bf581919ed34ce09da363bd201bc3b9-wsl-pro.service-2GZNo6
drwxr-xr-x 2 root root 4096 May 5 05:43 test
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
netstat command
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp# netstat -tulnp |grep -i vault
tcp 0 0 127.0.0.1:8200 0.0.0.0:* LISTEN 253/vault
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp# netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 213/systemd-resolve
tcp 0 0 127.0.0.54:53 0.0.0.0:* LISTEN 213/systemd-resolve
tcp 0 0 127.0.0.1:8200 0.0.0.0:* LISTEN 253/vault
udp 0 0 127.0.0.54:53 0.0.0.0:* 213/systemd-resolve
udp 0 0 127.0.0.53:53 0.0.0.0:* 213/systemd-resolve
udp 0 0 127.0.0.1:323 0.0.0.0:* -
udp6 0 0 ::1:323 :::* -
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
mkdir command
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp# mkdir test/dqsw/aqw/eswqs/edd/cwq/seas/
mkdir: cannot create directory ‘test/dqsw/aqw/eswqs/edd/cwq/seas/’: No such file or directory
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp# mkdir -p test/dqsw/aqw/eswqs/edd/cwq/seas/
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp#
root@DESKTOP-CL9FNGA:tmp# tree test
test
└── dqsw
└── aqw
└── eswqs
└── edd
└── cwq
└── seas
7 directories, 0 files
root@DESKTOP-CL9FNGA:tmp#
less command
root@DESKTOP-CL9FNGA:log#
root@DESKTOP-CL9FNGA:log# less syslog
root@DESKTOP-CL9FNGA:log#
root@DESKTOP-CL9FNGA:log#
root@DESKTOP-CL9FNGA:log#
root@DESKTOP-CL9FNGA:log# pwd
/var/log
root@DESKTOP-CL9FNGA:log#
how to find biggest file in linux
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# find . -maxdepth 1 -type f -exec ls -lS {} + | head -n 1
-rw-r--r-- 1 root root 67517785 Dec 15 17:33 ./awscliv2.zip
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# find . -maxdepth 1 -type f -exec ls -lS {} + | head -n 1 |awk '{print $5}'
67517785
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# find . -maxdepth 1 -type f -exec ls -lS {} + | head -n 1 |awk '{print $9}'
./awscliv2.zip
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# find . -maxdepth 1 -type f -exec ls -lS {} + | head -n 1 |awk '{print $9}'| awk -F "/" '{print $2}'
awscliv2.zip
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# ls -l
total 65972
drwxr-xr-x 3 root root 4096 Apr 8 03:13 GIT
drwxr-xr-x 3 root root 4096 Dec 13 19:24 aws
-rw-r--r-- 1 root root 67517785 Dec 15 17:33 awscliv2.zip
-rwx------ 1 root root 11903 Dec 14 17:09 get_helm.sh
drwxr-xr-x 3 root root 4096 Apr 8 03:12 kong-routing-stack
drwx------ 3 root root 4096 Dec 27 06:01 snap
drwxr-xr-x 5 root root 4096 Apr 8 03:19 venv
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~#
root@DESKTOP-CL9FNGA:~# pwd
/root