Accueil > Système > Quick Reference Guide For Linux Commands

Quick Reference Guide For Linux Commands

27/02/2024 Categories: Système Tags: ,
Print Friendly, PDF & Email

Linux command shelf is a quick reference guide for all linux user who wish to learn linux commands. Commands are divided into 15 categories , which would be more easier to understand what commands to be used in specific requirement. The pdf format of linux command shelf is also available. You could reach Bobbin Zachariah the author of this guide for any comments or corrections.

You can download the latest version of linux command shelf in pdf format. Current linux command shelf version is 1.1. This guide can be used by both advanaced and new linux users , provided the best efforts to give most relevant linux commands.

You can navigate to each section using the index that is places on the right hand side of this page or just below. If you feel hard to understand any command please let me know on my above profile page.

1. SYSTEM

# uname –a                       # Display linux system information
# uname –r                       # Display kernel release information
# cat /etc/redhat_release        # Show which version of redhat installed
# uptime                         # Show how long the system has been running + load
# hostname                       # Show system host name
# hostname -i                    # Display the IP address of the host
# last reboot                    # Show system reboot history
# date                           # Show the current date and time
# cal                            # Show this month calendar
# w                              # Display who is online
# whoami                         # Who you are logged in as
# finger user                    # Display information about user

2. HARDWARE

# dmesg                          # Detected hardware and boot messages
# cat /proc/cpuinfo              # CPU model
# cat /proc/meminfo              # Hardware memory
# free -m                        # Used and free memory (-m for MB)
# lspci -tv                      # Show PCI devices
# lsusb -tv                      # Show USB devices
# lshal                          # Show a list of all devices with their properties
# dmidecode                      # Show DMI/SMBIOS: hw info from the BIOS
# hdparm -i /dev/sda	         # Show info about disk sda
# hdparm -tT /dev/sda	         # Do a read speed test on disk sda
# badblocks -s /dev/sda	         # Test for unreadable blocks on disk sda

3. STATISTICS

# top                              # Display and update the top cpu processes
# mpstat 1                         # Display processors related statistics
# vmstat 2                         # Display virtual memory statistics
# iostat 2                         # Display I/O statistics (2sec Intervals)
# tail -n 500 /var/log/messages    # Last 10 kernel/syslog messages
# tcpdump -i eth1                  # Capture all packets flows on interface eth1
# tcpdump -i eth0 'port 80'        # Monitor all traffic on port 80 ( HTTP )
# lsof                             # List all open files belonging to all active processes.
# lsof -u testuser                 # List files opened by specific user
# free –m                          # Show amount of RAM
# watch df –h                      # Watch changeable data continuously

4. USERS

# id                                  # Show the active user id with login and group
# last                                # Show last logins on the system
# who                                 # Show who is logged on the system
# groupadd   admin                    # Add group "admin" 
# useradd -c  "Sam Tomshi" -g admin -m sam  # Create user "sam" and add to group "admin"
# userdel sam                         # Delete user sam
# adduser sam                         # Add user "sam"
# usermod                             # Modify user information

5. FILE COMMANDS

# ls –al                                # Display all information about files/ directories
# pwd                                   # Show the path of current directory
# mkdir directory-name                  # Create a directory 
# rm file-name                          # Delete file
# rm -r directory-name                  # Delete directory recursively 
# rm -f file-name                       # Forcefully  remove file
# rm -rf directory-name                 # Forcefully remove directory recursively
# cp file1 file2                        # Copy file1 to file2
# cp -r dir1 dir2                       # Copy dir1 to dir2, create dir2 if it doesn’t  exist
# mv file1 file2                        # Rename or move file1 to file2. If file2 is an existing directory , move file1 into directory file2
# ln –s  /path/to/file-name  link-name  # Create symbolic link to file-name
# touch file                            # Create or update file
# cat > file                            # Place standard input into file
# more file                             # Output the contents of file
# head file                             # Output the first 10 lines of file
# tail file                             # Output the last 10 lines of file
# tail -f file                          # Output the contents of file as it grows starting with the last 10 lines
# gpg -c file                           # Encrypt file
# gpg file.gpg                          # Decrypt file

6. PROCESS RELATED

# ps                               # Display your currently active processes
# ps aux | grep 'telnet'           # Find all process id related to telnet process
# pmap                             # Memory map of process
# top                              # Display all running processes
# kill pid                         # Kill process with mentioned pid id
# killall proc                     # Kill all processes named proc
# bg                               # Lists stopped or background jobs
# fg                               # Brings the most recent job to foreground
# fg n                             # Brings job n to the foreground

7. FILE PERMISSION RELATED

# chmod octal file-name     # Change the permissions of file to octal , which can be found separately for user, group and world
octal value 
4 - read
2 – write
1 – execute
Example 
# chmod 777 /data/test.c                   # Shows rwx permission for owner , rwx  permission for group, rwx permission for world
# chmod 755 /data/test.c                   # Shows rwx permission for owner,rw for group and world
# chown owner-user file                    # Change owner of the file
# chown owner-user:owner-group  file-name  # Change owner and group owner of the file
# chown owner-user:owner-group directory   # Change owner and group owner of the directory
Example 
# chown bobbin:expertslogin test.txt
# ls -l test.txt
-rw-r--r-- 1 bobbin expertslogin 0 Mar 04 08:56 test.txt

8. NETWORK

# ifconfig –a                  # Display all network ports and ip address
# ifconfig eth0                # Display specific  ethernet port ip address and details
# ethtool eth0                 # Linux tool to show ethernet status
# mii-tool  eth0               # Linux tool to show  ethernet status
# ping host                    # Send echo request to test connection
# whois domain                 # Get who is information for domain
# dig domain                   # Get DNS information for domain
# dig  -x host                 # Reverse lookup host
# host google.com              # Lookup DNS ip address for the name
# hostname –i                  # Lookup local ip address
# wget file                    # Download file
# netstat  -tupl               # List active connections to / from system

9. COMPRESSION / ARCHIVES

# tar cf home.tar  home              # Create tar named home.tar containing home/
# tar xf file.tar                    # Extract the files from file.tar
# tar czf  file.tar.gz  files        # Create a tar with gzip compression
# tar xzf file.tar.gz                # Extract a tar using gzip
# tar cjf file.tar.bz2   -           # Create a tar with bzip2 compression
# gzip file                          # Compress file and renames it to file.gz

10. INSTALL PACKAGE

# rpm -i pkgname.rpm                         # Install rpm based package 
# rpm -e pkgname                             # Remove package
Install from source
./configure
make
make install

12. LOGIN (SSH AND TELNET)

# ssh user@host                         # Connect to host as user
# ssh  -p port user@host                # Connect to host using specific port
# telnet host                           # Connect to the system using  telnet port

13. FILE TRANSFER

scp
# scp file.txt   server2:/tmp                   # Secure copy file.txt to remote host  /tmp folder
# scp nixsavy@server2:/www/*.html   /www/tmp    # Copy *.html files from remote host to current system /www/tmp folder
# scp -r nixsavy@server2:/www   /www/tmp        # Copy all files and folders recursively from remote server to the current system /www/tmp folder
rsync
# rsync -a /home/apps /backup/                  # Synchronize source to destination
# rsync -avz /home/apps expertslogin@192.168.10.1:/backup    # Synchronize files/directories between the local and remote system with compression enabled

14. DISK USAGE

# df –h                         # Show free space on mounted filesystems
# df -i	                        # Show free inodes on mounted filesystems
# fdisk -l	                # Show disks partitions sizes and types (run as root)
# du -ah                        # Display disk usage in human readable form 
# du -sh                        # Display total disk usage on the current directory

15. DIRECTORY TRAVERSE

# cd ..                              # To go up one level of the directory tree
# cd	                             # Go to $HOME directory
# cd /test                           # Change to /test directory

– See more at: http://www.expertslogin.com/guide/linux-command-shelf.html#sthash.NHssgdb2.dpuf

Lire aussi:  What are good open-source log monitoring tools on Linux ?
Categories: Système Tags: ,
Les commentaires sont fermés.