You know? Linux has a number of different ways of operation, graphical interface and text interface, using command operation, how to use these commands, can be in the text interface to obtain a large number of command instructions, and do not need to hard back some of the command options and parameters, this is the article to introduce. These include basic commands, file and directory management commands, disk with file System management commands, files with file system compression and packaging commands.
OK, let's get into the theme:
I. X window vs. command-line mode switch
The Linux desktop operation is almost exactly the same as window, so it's not much more, so how do I switch between x window and command-line mode (also called Terminal Interface Terminal or console)? Linux By default provides 6 terminal to let the user log in, switch to use CTRL+ALT+F1~F6, the system named it Tty1~tty6, then the question, how to return to the graphical interface? Ctrl+alt+f7 or STARTX, the graphical interface opens the virtual terminal using Ctrl+alt+t
Two. Basic command operation
(1) Correct method of shutting down the machine
Linux is a multi-user multitasking operating system, you can not see the screen behind the fact that there may be many people at the same time working on your host, such as browsing the web, transfer files, etc., if the power is directly off the other person data may be interrupted.
viewing system usage Status
W.H.O. |
View who is currently online |
Netstat-a |
View Network Online Status |
Ps-aux |
View Background Execution Program |
Notify online users when the shutdown
Sync |
Synchronizes the current in-memory data to the hard disk |
Shutdown-h now |
Shut down now (recommended) |
Reboot |
Restart |
Poweroff-f |
Shutdown |
Halt |
Shutdown |
(2) Simple command
Display date and time: date;
Display calendar: Cal;
Easy to use calculator: BC;
(3) Important Hotkey tab,ctrl-c,ctrl-d
tab is followed by the first command of a string of commands, then the command completion, followed by the second command of a sequence of commands, to fill the file. (Try pressing Tab two times)
Ctrl-c (i.e. CTRL and C keys pressed simultaneously): interrupts the current program
Ctrl-d: End of keyboard input, quite have exit
(4) man page and Info page
Haha, people are not afraid to remember the command parameters Ah, do not worry, Man,info command will help you remember Oh, try man date command
man-f [command or data] <==>whatis try man-f date, and try to understand.
man-k [command or data] <==>apropos
Info and man are about the same, specific differences on the Internet a lot of, will not write
There's a--help, and it's a command aid.
Try date--help and see what's out there.
(5) Ultra-simple text editor: Nano
In fact, the most important editor is VI, which is said later
Nano [filename] You can open the file.
(6) Change the root password:
passwd
(7) Clear screen:
Ctrl+l
Three. linux file and directory Management command operations
Relative path: path is not written by/write, such as from/usr/share/doc to/usr/share/man, can be written as CD. /man;
Absolute path: The path must be written by the root directory/write, such as/HOME/HPW
Directory-related Operations command:
Ls |
List files under Directory-L: Show file Properties,-A: Show hidden files |
Cd |
Switch directories |
Pwd |
Show current directory |
Mkdir |
New Directory-P: You can create your own multi-level directory,-M: You can add permissions when creating a directory, such as |
RmDir |
Delete an empty directory (note that you cannot delete a directory that is not empty) |
Note: LS is displayed in different colors:
Blue--Directory Green--executable file red--compressed file light blue--Link file Pink--image file
Yellow--Device file gray--Other files
File and Directory Management
CP (copy) |
Copy a file or directory-r: Recursive execution,-I: ask whether to perform a-p: Copy along with permissions |
RM (remove) |
Remove a file or directory-r: Recursive execution,-I: query,-F enforcement |
MV (move) |
Moving files and directories-R: Recursive execution,-I: Asking |
Gets the path's file name and directory name
File Content Lookup
Cat |
Show file contents starting from first line-N: Print travel number |
Tac |
Starting from the last line, you can see that the TAC is an inverted form of cat, huh? |
nl |
When displayed, the output line number by the way |
More |
A page-by-page display of the contents of a file |
Less |
With the more class try, but better than the more, it can flip ahead |
Head |
Just a few lines. |
Tail |
Just look at the end. |
Od |
Read the contents of a file in a binary way |
Modify file time or create a new file: Touch
In Linux, a lot of time parameters will be recorded, in fact, there are three major changes in time
Modification (Mtime): When the content data of the file is changed, the time will be updated, the file permissions or properties will not be updated
Status Time (CTime): Updated when the status of the file changes, such as permissions or attributes changed
Access Time (Atime): When the contents of a file are used, the read times are updated, and if we use cat to read/etc/man.config, the atime of the file is updated.
Touch: Create an empty file; Modify the date of a file to the current date (Mtime and Atime)
-A: Modify access time
-C: The time to modify the file, if the file does not exist do not create a new file
-D: the date after which you want to modify it instead of the current time
-M: Modify Mtime only
-T: The time later to be modified instead of the current time, in the format [YYMMDDHHMM]
Permission Modification Command:
CHGRP: Change file to user group syntax: CHGRP-[r] User group name file or directory-R indicates whether or not recursively modified directory with subdirectories modified
Chown: Change file owner Syntax ditto
chmod: Change the permissions of a file syntax: chmod-[r] Permissions digital file or directory Note: Each permission number comparison table: R:4 w:2 x:1-:0 Example: Owner = rwx = 4+2+1 = 7 Group = rwx = 4+2+1 = 7 others =---= 0+0+0=0 Example: Chown 770 file or directory name
In addition to the appeal use the number modification permission can also use symbols for permission modification
chmod |
U (user) G (Group) O (Other) A (full identity) |
+ (Join) -(remove) = (set) |
R W X |
File or directory |
File Special permissions: Suid,sgid,sbit (here will not write, interested can own Baidu encyclopedia OH)
Viewing file types: Files
If you want to know the basic data of a file, such as making it into ASCII or data, or making binary, where there is no use of the dynamic function library (share libary) and so on, you can use the file command to view
Query for script file name
Which (looking for "execute file") such as LS the common command where? can be used which LS
Search for files
Whereis (looking for a specific file)
Locate: You can get results after entering "part of file name" directly in the back
Find: Very powerful command of Baidu Encyclopedia find
Four. Linux disk and File System Management command operations
Disk-to-directory capacity: df,duhttp://hpw123.net/424346976/
DF: List The overall disk usage of the file system
Du: Evaluating the disk usage of the file system (commonly used to estimate the capacity of the catalog)
Connection file: ln (-S is a symbolic connection, not a hard connection)
Connecting files with hard connections and symbolic connections (that is, shortcuts)
partitioning, formatting, checking and mounting of disks: Fdisk,mkfs,fsck,badblocks,mount,umount
Mount Disc: Mount-t iso9660/dev/cdrom/mnt/cdrom
Unmount disc: Umount/mnt/cdrom or Umount/dev/cdrom
Mount USB: Mount/dev/sdb1/mnt/usb
Mount ISO Image: Mount-t iso9660-o loop iso image file/mnt/cdrom
Five. File and file system compression and Packaging command operations
Common compressed file extensions:
*. Z |
Compress Program Compressed files |
*.gz |
Files that are compressed by the GZIP program |
*.bz2 |
BZIP2 Program Compressed Files |
*.tar |
The TAR program is packaged with data that has not been compressed |
*.tar.gz |
Tar program packaged files, which are compressed by gzip |
*.tar.bz2 |
The TAR program packages the files, which are compressed by bzip2 |
Well, as for the compression command a lot of, because the compression software is much better
Here's a memory of the following.
Compression: Tar-jcv-f filename.tar.bz2 The name of the file or directory to be compressed
Enquiry: Tar-jtv-f filename.tar.bz2
Decompression: Tar-jxv-f filename.tar.bz2-c to extract the directory
OK, today's content is probably the case, if there is something wrong, ask the big God, we see in the next article:)
Now let's take it easy: Sketch art, Beautiful sketch (video)
- Related articles recommended:
- Linux User management commands (Useradd, adduser)
- What are the Linux restart commands? Linux Restart command Daquan
- Examples of Linux finger command usage
- This article from: Hobby Linux Technology Network
- This article link: http://www.ahlinux.com/start/cmd/6955.html
Easy to learn Linux Tutorials III play Linux common commands