In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "what commands are commonly used in Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Every user who has a certain grasp of the Linux system must begin to learn some common commands of the Linux system and the application of these two commands with vi and gdb. The editor has also been studying recently, so I will share the information with you.
1.ls command
Ls displays the list of files in the current directory by default
Ls-a shows all files, including hidden files
Ls-l displays file properties, including size, date, symbolic link, read / write and executable
2.cd command
Cd dir changes to the dir directory under the current directory
Cd.. Switch to the previous directory
Cd ~ switch to user directory, such as root user, then switch to / root
3.rm command
Rm file deletes a file
Rm-rf dir deletes the entire directory called dir under the current directory
4.cp command
Cp source target copies the file source to target
Cp-av source_dir target_dir copies the entire directory, and the two directories are exactly the same
Cp-fr source_dir target_dir copies the entire directory, and copies it unlinked. When the source directory has symbolic links, the two directories are different.
5.mv command
Mv source target renames a file or directory source to target
6.diff command
Diff-ruN dir1 dir2 > compare files in directory 1 and directory 2
Generate patch file
Diff-ruN dir1 dir2 > dir.diff
Enter directory 1 to patch
Patch-p1 <.. / dir.diff
7.echo command
Echo message displays a string of characters
8.cat command
Cat file displays the contents of the file, which is the same as DOS's type
Cat file | more displays the contents of the file and transfers it to the more program to achieve distributed display. The same function can be achieved by using the command less file.
More distribution command, which is generally sent to it through a pipeline, such as ls | more
9.du command
Du calculates the capacity of the current directory
Du-sm / root calculates the capacity of the / root directory in M
10.find command
Find-namefile looks in the / path directory to see if there is a file file
11.grep command
Grep-r "chars". / find the string chars-r for all files in the current directory for recursive lookup subdirectories
Ctrl+c exit recursion
The use of 12.vi
Vi file Editing File file
The original basic use and command of vi:
Vi is divided into editing status and command status. To enter a command, press ESC, exit the editing state, and then enter the command.
Common commands are:
: X (exit)
: x! (exit without saving)
W (save file)
: w! (write file without asking)
R file (read file file)
:% s/oldchars/newchars/g (change all strings oldchars to newchars)
I enter the edit insert state
ESC exits editing state
13.man command
Man ls reads the help about the ls command
14. Start the command to shut down the computer
Reboot restart the computer
Halt shuts down the computer
Init 0 shuts down all applications and services and enters a pure operating environment
Init 1 restart applications and services
Init 6 restart the computer
15.tar command
Tar-xfzv file.tgz decompresses the file file.tgz
Tar-zcvf file.tgz compresses a file or directory to file.tgz
Gzip directory.tar will overwrite the original file to generate a compressed directory.tar.gz
Gunzip directory.tar.gz overwrites the original file and decompresses it to generate an uncompressed dirrectory.tar previous page 1234 the next page is 4 pages
16.dmesg, uname command
Dmesg displays kernel startup and driver loading information
Uname-a shows the type of operating system
17.string command
String file displays the content of ASCII characters in file files
18.rpm command
Rpm-ihv program.rpm installer program and displays the installation process
19. File directory management command
Su root switches to superuser
Chmod axix file sets the file file to be executable. Script class files must be set up in this way, otherwise you have to use bash file to execute them.
Chmod 666 file sets the file file to read / write
Chown user / dir sets the / dir directory to be owned by user
20.mknod command
Mknod / dev/hda1 b 3 1 creates a block device hda1 with master device number 3 and slave device number 1, that is, the first partition of the master hard disk
Mknod / dev/tty1 c 4 1 creates a character device tty1 with master device number 4 and slave device number 1, that is, the first tty terminal
Touch / tmp/running creates a temporary file running under / tmp and disappears after reboot
21. Commands for disk management
Fdisk / dev/hda is like a fdisk that executes dos
Mount-t ext2 / dev/hda1 / mnt loads / dev/hda1 to the / mnt directory
Df displays information about file system mounts
Mount-t nfs 192.168.1.1:/sharedir / mnt loads the shared directory sharedir of the nfs service into the / mnt/nfs directory
Umount / mnt uninstalls the / mnt directory and the / mnt directory must be idle
Sync flushes buffers to synchronize content with disk
Mkfs.ext2 / dev/hda1 format / dev/hda1 is in ext2 format
Dd if=/dev/zero of=root.ram bs=1024, count=1024 generates a 1m block device that can be used as a partition of a hard disk
twenty-two。 Commands related to program development
Gcc hello.c-o hello compiles hello.c into a binary execution file called hello
Ldd program shows which libraries the program uses
23. System related command
Ps displays the current system process information
Ps-ef displays all process information of the system
Kill-9500 kills the program with process number 500
Top shows the activity of system processes as a percentage of CPU resources
Free display system and swap usage
After the end of the program program, time program will calculate the time it takes for program to run back.
Network command
The IP address of ifconfig eth0 192.168.1.2 bundled Nic 1 is 192.168.1.2
24. Log in to the network server
Telnet 192.168.1.1 Log in to the telnet Server with IP 192.168.1.1
Ftp 192.168.1.1 Log in to ftp Server
The commands listed by the editor are long, but they are all very important. Interested users had better practice and master each command in person. Talking without practice will certainly have no effect.
This is the end of the content of "what commands are commonly used in Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.