Posted On May 2, 2019

Linux: More Basic Commands

kimconnect 0 comments
blog.KimConnect.com >> Linux >> Linux: More Basic Commands
Networking

Ping 1 Time

ping google.com -c 1 #c is abbreviation for count

Check Networking

ifconfig
ip addr

How to Check Open Ports

sudo netstat -tulpn #Shows address and port
System Admin

Emulate root

sudo -s #This prevents the system from asking for the sudo password after timer expires
exit #exit sudo mode

Emulate another user

su kimconnect #To become the user kimconnect
exit #end user masquerade

How to check kernel version

uname -a

Trigger a system checkup on next reboot

sudo touch /forcefsck

Timed Shutdown

sudo shutdown -h 5 #Shutdown. Halt everything in 5 minutes

Cancel Shutdown timer

sudo shutdown -c

Check CPU usage of PHP

ps aux | grep apached

Check CPU/Memory Usage of All Processes

top #preinstalled in most systems
htop #new top package, human readable

Check Services

service SERVICENAME status #Older unix command
systemctl status SERVICENAME #Systemd command

Stop Processes

killall PROCESSNAME #instantly halt a process and its related
pkill #similar to killall with more chances of success
File & Folder Manipulations

Get folder size

sudo du -sh /var

admin@nfs:~# sudo du -shc /export/pihole
108M /export/pihole
108M total

sudo du -h --max-depth=2 /export/pihole

admin@nfs:~# sudo du -h --max-depth=2 /export/pihole
8.0K /export/pihole/dnsmasq
8.0K /export/pihole/pihole/migration_backup
108M /export/pihole/pihole
108M /export/pihole

List hidden files

ls -la #long format, all files

Check Disk Space

df -ah #disk free all human readable

Check folder/directory size

du -sh /var/www/html #disk usage sum human readable

Find Universal Identifier for Drives (UUID)

sudo blkid

Check for Existing Mounts

mount

How to Create a Mount

mount /dev/sda2 /mnt #sda2 = disk 1 partition 2

Check for Persistent Mounts (Mounts at Bootup)

less /etc/fstab

Create a file

touch testfile.txt #This command also updates the last modified time attribute

Move and rename a file

mv file1.txt ~/file1.txt_backup #Move file1.txt into home directory and rename it with a _backup suffix

Find the directory where an App is installed

which google-chrome

less is the same as more + cat

less somefile.txt
cat somefile.txt | more

Search for a phrase inside a file

grep -i kimconnect.com domains.txt  #Ignore case during grep
strings domains.txt | grep kimconnect.com | less #Alternative method

Count lines, words, and letters

wc domains.txt

Switch between different files

vi text1.txt
Keys Combo: Control+Z
vi text2.txt
Keys Combo: Control+Z
jobs  #Shows tasks in the background
fg %2  #Join the job index

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Logical Volume Management: A Practical Illustration

# Runas root kim@kimlinux:~$ sudo su - # List all disks fdisk -l | grep…

Problem: NextCloud Would Not Start Due to Versioning Variance

This issue has occurred when NextCloud has been upgraded after deployment. Its source docker container…

Some Common Gitlab Commands

To ignore SSL Cert errors: git config --global http.sslVerify "false"   # checkout changed file…