Linux Cmds
Linux Cmds
Linux Cmds
2 – HARDWARE INFORMATION
3 – PERFORMANCE MONITORING AND STATISTICS
4 – USER INFORMATION AND MANAGEMENT
5 – FILE AND DIRECTORY COMMANDS
6 – PROCESS MANAGEMENT
7 – FILE PERMISSIONS
8 – NETWORKING
9 – ARCHIVES (TAR FILES)
10 – INSTALLING PACKAGES
11 – SEARCH
12 – SSH LOGINS
13 – FILE TRANSFERS
14 – DISK USAGE
15 – DIRECTORY NAVIGATION
1 – SYSTEM INFORMATION
# Show the current date and time
date
# Display Linux system information
uname -a
# Show this month's calendar
cal
# Display kernel release information
uname -r
# Display who is online
w
# Show which version of Red Hat installed
cat /etc/os-release
# Who you are logged in as
Whoami
# Show how long the system has been running + load
uptime
# Show system reboot history
last reboot
# Show system host name
hostname
# Interactive process viewer (top alternative) # List all open files on the system
htop lsof
# Display virtual memory statistics # Display free and used memory ( -h for human
vmstat 1 readable, -m for MB, -g for GB.)
free -h
# Display I/O statistics
iostat 1 # Execute "df -h", showing periodic updates
watch df -h
# Display the last 100 syslog messages
(Use /var/log/syslog for Debian based systems.)
tail -100 /var/log/messages
# Capture and display all packets on interface eth0
tcpdump -i eth0
4 – USER INFORMATION AND MANAGEMENT
# Display the user and group ids of your current user.
id
# Display the last users who have logged onto the system.
last
# Show who is logged into the system. # Delete the john account.
who userdel john
# Show who is logged in and what they are doing. # Add the john account to the sales group
w usermod -aG sales john
# Create an account named john, with a comment of "John Smith" and create the user's
home directory.
useradd -c "John Smith" -m john
5 – FILE AND DIRECTORY COMMANDS
# List all files in a long listing (detailed) format
ls -al
# Create a directory
mkdir directory
# Rename or move file1 to file2. If file2 is an existing directory, move file1 into
directory file2
mv file1 file2
# Create an empty file or update the access and modification times of file.
touch file
# View the contents of file
cat file
# Display the last 10 lines of file and "follow" the file as it grows.
tail -f file
6 – PROCESS MANAGEMENT
# Display your currently running processes
ps
U G W
rwx rwx rwx chmod 777 filename
rwx rwx r-x chmod 775 filename
rwx r-x r-x chmod 755 filename
rw- rw- r-- chmod 664 filename
rw- r-- r-- chmod 644 filename # NOTE: Use 777 sparingly!
LEGEND
U = User
G = Group
W = World
r = Read
w = write
x = execute
- = no access
8 – NETWORKING
# Display all network interfaces and IP address
ip a
# Download http://domain.com/file
wget http://domain.com/file
# Install package.
yum install package
# Remove/uninstall package.
yum remove package
# Copy all files and directories recursively from server to the current system's /tmp folder.
scp -r server:/var/www /tmp
# Synchronize files/directories between the local and remote system with compression
enabled
rsync -avz /home server:/backups/
14 – DISK USAGE
# Display disk usage for all files and directories in human readable format
du -ah