Linux commands
In working and learning with the Linux environment, we have more time to beat the fingers on the keyboard. Here, let's just say that the Linux command is used.
In a Linux environment, it is clear that you cannot write down all the commands and their rules of use, soman,help Two commands are especially important.
About the man command, emphasizing
about what we need to find the level, scene, and attention of the command to find
Next is, tell us the options given by the man page, usually we need to be aware of: Description (DESCRIPTION), return value (returns).
Look up a string in man as:/str up,? STR up Lookup
Eg: find the LS character in the manual:/ls
Then, press N (next)
File commands
ls– Listing Directories
ls-al– using formatting to list hidden files
CD DIR-Change directory to Dir
cd– Change to home directory
pwd– Show current directory
mkdir dir– Create directory dir mkdir-p dir1/dir2-Recursive create Dir1,dir1 with Dir2
RM file– Delete file rm-r dir– Delete directory dir
Rm-f file– Force Delete file rm-rf dir– Force delete directory dir *
CP file1 file2– copy file1 to File2
Cp-r dir1 dir2– copy Dir1 to Dir2; Create the Dir2 if it does not exist
MV File1 file2– to rename or move file1 to file2; If File2 is an existing directory, move file1 to the directory File2
Ln-s file link– Creating a symbolic connection to a file link
Touch file– Create File
Cat > file– Add standard input to file
More file– View the contents of file
Head file– View the first 10 lines of file
Tail file– View the following 10 lines of file
Tail-f file– Start viewing the contents of file from the following 10 lines
Process Management
PS – Displays the current active process Pstree-tree display process
top– Show all running processes
Kill pid– Process ID PID kill-l-display signal information
Killall proc-Kill all the processes called Proc *
bg– list jobs that are stopped or in the background
fg– bring the latest assignments to the front desk
FG N – Bring the assignment N to the foreground
File permissions
chmod octal file– Change permissions for file
4– Read (R)
Write (W)
---Execute (x)
Example:
chmod 777– Add read, write, and execute permissions for all users
chmod 755– Add rwx permissions for owners, add RX permissions for groups and other users
See Man chmod for more options.
Ssh
SSH [email protected]– Connect as user user to host
Ssh-p Port [e-mail protected]– connect to host as user user
Ssh-copy-id [Email protected]– add key to host for no password login
Search
grep pattern files– searches for content in files that match pattern
Grep-r pattern dir– recursively searches for content in Dir that matches the pattern
Command | grep pattern– searches the command output for matching pattern content
System Information
date– display the current date and time
Cal – Show calendar for the current month
uptime– displays the time the system is running from power on to now
W – Show logged in user
whoami– View your current user name
Finger user– Display information about the user
uname-a– displaying kernel information
cat/proc/cpuinfo– Viewing CPU information
cat/proc/meminfo– Viewing memory information
Man command– instruction manual for display command
df– Display of disk usage
du– Display of directory space consumption
free– display of memory and swap area occupancy
Compression
Tar CF File.tar files– Creating a tar file containing files
File.tar
Tar XF file.tar– extract files from File.tar
Tar czf file.tar.gz files– created with Gzip compression
Tar file
Tar xzf file.tar.gz– extracting tar files using Gzip
Tar cjf file.tar.bz2– using BZIP2 compression to create tar text
Thing
Tar xjf file.tar.bz2– extracting tar files using BZIP2
Gzip file– compress file and rename it to file.gz
Gzip-d file.gz– to extract file.gz to file
Internet
Ping host–ping host and output results
Whois domain– access to domain whois information
Dig domain– get DNS information for domain
Dig-x host– Reverse Lookup host
wget file– Download file
Wget-c file– Breakpoint Continuation
Installing from source code
./configure
Make
Make install
Dpkg-i pkg.deb– installation package (Debian)
RPM-UVH pkg.rpm– installation package (RPM)
Shortcut keys
ctrl+c– Stop the current command
ctrl+z– Stop the current command and use FG to recover
ctrl+d– logoff The current session, similar to exit
ctrl+w– Delete words from the current line
ctrl+u– Delete an entire row
!! -Repeat the last command
exit– Log off the current session
* Use carefully.
Linux command Details (i)