0% found this document useful (0 votes)
32 views

Linux-Cheat-Sheet 2

Uploaded by

Suresh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
32 views

Linux-Cheat-Sheet 2

Uploaded by

Suresh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
1) System uname uname -r uptime hostname hostname -i last reboot date ‘timedatect1 cal whoami, finger username Displays Linux system information Displays kernel release information Displays how long the system has been running including load average Shows the system hostname Displays the IP address of the system Shows system reboot history Displays current system date and time Query and change the System clock Displays the current calendar month and day Displays currently logged in users in the system Displays who you are logged in as Displays information about the user 2) Hardware dmesg cat /proc/cpuinfo cat /proc/meminfo Ashw Asblk free Ispci -tv lsusb -tv Displays bootup messages Displays more information about CPU e.g model, model name, cores, vendor id Displays more information about hardware memory e.g. Total and Free memory Displays information about system's hardware configuration Displays block devices related information Displays free and used memory in the system (-m flag indicates memory in MB) Displays PCI devices in a tree- like diagram. Displays USB devices in a tree-like diagram dmidecode hdparm -i /dev/xda hdparm -tT /dev/xda <:code> badblocks -s /dev/xda 3) Users id last who groupadd "admin" adduser "Sam" userdel "Sam" usermod Displays hardware information from the BIOS Displays information about disk data Conducts a read speed test on device xda Tests for unreadable blocks on disk Displays the details of the active user e.g. uid, gid, and groups Shows the last logins in the system Shows who is logged in to the system ‘Adds the group ‘admin’ Adds user Sam Deletes user Sam Used for changing / modifying user information 4) File Commands As -al pwd mkdir ‘directory_name* rm file_name rm - filename rm -r directory_name pm -rf directory_name cp file1 file2 cp -r dirt dir2 Lists files - both regular & hidden files and their permissions as well Displays the current directory file path Creates a new directory Removes a file Forcefully removes a file Removes a directory recursively Removes a directory forcefully and recursively Copies the contents of filet to file2 Recursively Copies dirl to dir2. dir2 is my filet file2 In -s /path/to/file_name Link_name touch file_name cat > file_name more file_name head file_name tail file_name gpg -c file_name gpg file_name.gpg we xargs created if it does not exist, Renames file1 to file2 Creates a symbolic link to file_name Creates a new file Places standard input into a file Outputs the contents of a file Displays the first 10 lines of a file Displays the last 10 lines of a file Encrypts a file Decrypt a file Prints the number of bytes, words and lines ina file Executes commands from standard input 5) Process Related ps ps aux | grep "telnet" pmap top kill pid killall proc pkill process-name be fe fgn Lsof Display currently active processes Searches for the id of the process ‘telnet’ Displays memory map of processes Displays all running processes Terminates process with a given pid Kills / Terminates all processes named proc Sends a signal to a process with its name Resumes suspended jobs in the background Brings suspended jobs to the foreground job nto the foreground Lists files that are open by processes renice 19 PID pgrep firefox pstree makes a process run with very low priority find Firefox process ID visualizing processes in tree model 6) File Permission chmod octal filename Example chmod 777 /data/test.c chmod 755 /data/test.c chmod 766 /data/test.c chown owner user- file chown owner- user:owner-group ile_name chown owner- user:owner-group directory 7) Network ip addr show ip address add 192.168..1/24 dev etho ifconfig ping host Change file permissions of the file to octal Set rwx permissions to owner, group and everyone (everyone else who has access to the server) Set rwx to the owner and r_x to group and everyone Sets rwx for owner, nw for group and everyone Change ownership of the file Change owner and group owner of the file Change owner and group owner of the directory Displays IP addresses and all the network interfaces Assigns IP address 192.168.0.1 to interface eth0 Displays IP addresses of all network interfaces ping command sends an ICMP echo request to establish a connection to server / PC. whois domain dig domain dig -x host host google.com hostname -i weet file_name netstat -pnitu Retrieves more information about a domain name Retrieves DNS information about the domain Performs reverse lookup on a domain Performs an IP lookup for the domain name Displays local IP address Downloads a file from an online source Displays all active listening ports 8) Compression/Archives tar -cf home.tar home<: code> tar -xf files.tar tar -zevf home. tar.gz source- folder gzip file Creates archive file called 'home.tar’ from file home’ Extract archive file 'files.tar’ Creates gzipped tar archive file from the source folder Compression a file with .gz. extension 9) Install Packages rpm =i pkg_name. rpm rpm -e pkg_name Install an rpm package Removes an rpm package dnf install pkg_name Install package using dnf utility 10) Install Source (Compilation) «/configure Checks your system for the required software needed to build the program. It will build the Makefile containing the instructions required to effectively build the project Tt reads the Makefile to compile the program with the required operations. The nie process may take some time, depending on Yyour system and the size of the program The command installs the binaries in the make install _—_defaulsmodified paths after the compilation 11) Search grep “pattern’ files Search for a given pattern in files grep -r pattern dir Search recursively for a pattern ina given directory DOA Find all instances of the file find /home/ -name Find file names that begin with "index" ‘index’ in /home folder find /home -size Find files greater than 10000k in +10000k the home folder 12) Logi h host pene Securely connect to host as user ssh -p port_number Securely connect to host using a user@host ssh host Securely connect to the system via SSH default port 22 Connect to host via telnet peinet ghost default port 23 13) File Transfer sep file1.txt Securely copy filel.txt to server2/tmp server? in /tmp directory Synchronize contents in ‘shome/apps directory with Tbackup directory rsync -a /home/apps /backup/ 14) Disk Usage Displays free space on mounted df -| systems mal Displays free inodes on filesystems Pre Shows disk partitions, sizes, and types Displays disk usage in the current du -sh a human-readable findant! Displays target mount point for all filesystems mount device-path Mount a device mount-point 15) Directory Traverse Move up one level in the cde. directory tree structure Change directory to $HOME, ad directory cd /test Change directory to /test directory

You might also like