Linux Basics and Common commands (written interview required) __linux

Source: Internet
Author: User
Tags chmod create directory mkdir time 0 file permissions line editor
I. Basic USE

X window and text mode switching.
Usually we also call the text mode the terminal interface, terminal or console. Linux By default will provide six terminal to allow users to log in, the way to switch to use: [Ctrl] + [Alt] + [F1]~[f6] Combo button. The system will name [F1] ~ [F6] as the operating interface environment of Tty1 ~ Tty6. Press [Ctrl] + [Alt] + [F7] to go back to the X graphics window.
To start the X window in a plain text environment, you can use your account login at any of the Tty1~tty6 terminal interfaces (the next section of the method will be introduced), and then give the following command: [vbird@www ~]$ startx. Linux provides us with seven run level defaults, the most common of which is run level 3 and run Level 5.

Mans page
The meaning of several common numbers in querying data:
1 commands or executable files that users can manipulate in the shell environment
5 configuration file or the format of some files
8 Administrative commands available to system administrators
Man page key function:

Search for a man page description file for a particular command/file. [Vbird@www ~]$ Man-f Mans

[Vbird@www ~]$ man-f man 
Mans                  (1)  -format and display the on-line manual pages 
man                  (7)  -Macros T o Format man pages 
Man.config [Mans]     (5)  -Configuration data for Mans

But what if I'm looking for a "key word"?

[Vbird@www ~]$ Man-k Mans 
. [Builtins]         (1)  -Bash built-in commands, and you'll have a bash (1) 
. TP php [PHP]     (1)  -php Command line Interface ' CLI ' ... 
. (omitted in the middle) .... 
Zshall               (1)  -the Z Shell Meta-man page 
zshbuiltins          (1)  -zsh built-in 
commands Zshzle               (1)  -zsh command line editor

There are two more commands related to the man page:

[Vbird@www ~]$ whatis  [command or data]   <== equivalent to man-f [command or data] 
[vbird@www ~]$ Apropos [command or data]   <== equivalent man-k [command or data]

Info page
Info and man are used for similar purposes, both to query the use of commands or to format files. But with man page, a bunch of information. Info page is the file data into a single paragraph, each paragraph with its own page to compose, and on each page there are similar pages of "hyperlinks" to jump to different pages, each separate page is also called a node ( node).

Shutdown command
Consider when shutting down the computer. Observe the use of the system: if you want to see who is currently online, you can release the "who" command, and if you want to see the online status of the network, you can release the "netstat-a" this command, and to see the background running the program can run the "ps-aux" this command.
Several commands related to shutdown/reboot:
(1) Synchronize data to the hard drive: Sync
(2) The customary shutdown command: shutdown
(3) Reboot, Shutdown: Reboot, halt, Poweroff shutdown

[Root@www ~]#/sbin/shutdown [t-sec] [-ARKHNCFF] time [warning information] 
options and Parameters:- 
t sec:-T after plus seconds, which means "shutdown after a few seconds" meaning- 
k     : No, really. Shutdown, just send a warning message out. - 
R     : Reboot (Common) after the service of the system has been stopped (normal)- 
h: Shut down the     system immediately after the service is stopped. (commonly used) 
-N     : Shut down directly with shutdown function without the INIT program- 
F     : After shutting down and starting, force the bypass fsck disk check- 
f     : After the system restarts, force the fsck disk check 
  -c     : Cancels the content of the shutdown command that is already in progress. 
time   : This is the parameter that must be added. Specifies when the system shuts down. The example of time will be explained below. 
Example: 
[Root@www ~]#/sbin/shutdown-h ' I'll shutdown after mins ' 
# Tell everyone that the machine will be shut down in 10 minutes. And will appear in front of the current lander's screen. 
# What are the parameters? Here are a few.
Give a few examples:
[Root@www ~]# shutdown-h 
now shuts down immediately, in which now corresponds to the state of time 0 
[root@www ~]# shutdown-h 
system in today's 20:25 chapter shutdown, if at 21: 25 before issuing this command, the genius shutdown 
[root@www ~]# shutdown-h +10 
system 10 minutes after the automatic shutdown 
[root@www ~]# shutdown-r 
now system reboot 
immediately  [Root@www ~]# shutdown-r +30 ' The system will reboot '  
is restarted again in 30 minutes and displays the following information to all users online 
[root@www ~]# shutdown-k Now ' This system would reboot '  
only issue the parameters of the warning letter. The system does not turn off the computer. Scare people.
Reboot, Shutdown: Reboot, Halt, Poweroff
[Root@www ~]# Sync; Sync Sync Reboot 
[root@www ~]# shutdown-h now 
[root@www ~]# poweroff-f
Switch Run Level: init
Run Level 0: shutdown
Run Level 3: Plain text mode
Run Level 5: Contains graphics interface mode
Run Level 6: Reboot
[Root@www ~]# Init 0
two. File attributes and Permissions

Change Affiliation Group, CHGRP

[Root@www ~]# Chgrp [-r] dirname/filename ...
Options and Parameters:-
r: Continuous changes to recursive (recursive), that is, all files and directories in the secondary directory
  are updated to be the meaning of this group. Often used to change the status of all files in a directory.
Example:
[Root@www ~]# chgrp users Install.log
[root@www ~]# ls-l
-rw-r--r--  1 root users 68495 June 08:53 INSTALL.L OG
[root@www ~]# chgrp testing install.log chgrp:invalid
group name ' testing ' <== the error message is not found in this group name ~

Change file owner, Chown

[Root@www ~]# Chown [-r] Account name file or directory
[root@www ~]# Chown [-r] Account name: Group name file or directory
options and Parameters:-
R: Continuous change of recursion (recursive), i.e. Along with all the files in the secondary directory change
paradigm: Change the owner of the Install.log to bin this account:
[root@www ~]# chown bin Install.log
[root@www
~]# ls-l -rw-r--r--  1 Bin  users 68495 June 08:53 Install.log
Example: Change the owner and group of the Install.log back to root:
[root@www ~]# Chown root:root install.log
[root@www ~]# ls-l
-rw-r--r--  1 root root 68495 June 08:53 Install.log

Change permissions, chmod
There are two ways to set permissions, and you can use numbers or symbols to change permissions. Number Type Change file permissions
Linux files have nine basic permissions, respectively, owner/group/others three identity each have their own read/write/execute permissions, respectively, is r:4,w:2,x:1. Each of the three permissions (r/w/x) points for each identity (owner/group/others) needs to be cumulative.

[Root@www ~]# chmod [-r] XYZ file or directory
options and Parameters:
XYZ: is the permission attribute of the numeric type just mentioned, the addition of the RWX attribute value. -
R: Continuous changes to recursive (recursive), i.e. all files in the secondary directory will be changed
If you want to enable all permissions for the. bashrc file, then release:
[Root@www ~]# ls-al. BASHRC
-rw-r--r--  1 root 395  4 11:45. BASHRC
[root@www ~]# chmod. 777 Bashr C
[root@www ~]# ls-al. BASHRC
-rwxrwxrwx  1 root 395  4 11:45. BASHRC
Symbol Type Change file permissions
Basically nine permissions are (1) User (2) group (3) others three identities. Then we can represent the rights of three different identities by u, G, O. In addition, a represents all, the whole identity.

[Root@www ~]# chmod  u=rwx,go=rx  . BASHRC
# Note. The U=rwx,go=rx is connected, and there are no spaces in the middle.
[root@www ~]# chmod  a+w  . BASHRC
[[root@www ~]#  ] chmod a-x  . BASHRC
3. File and Directory Management

Directory-related actions:

CD (Transform directory)

PWD (Displays the current directory)

[Root@www ~]# pwd [-p]
options and Parameters:-
P  : shows the exact path instead of using the link path.
Example: Simply display the current working directory:
[Root@www ~]# pwd
/root   <== shows the Catalog ~
Example: It shows the actual working directory, not the directory name of the link file itself
[root@www   ~]# Cd/var/mail <== Note that/var/mail is a link file
[root@www mail]# pwd/var/mail to         list the current working directory
[<== root@www mail]#
/var/spool/mail   <== What's going on. There is no plus-p difference a lot ~
[root@www mail]# ls-ld/var/mail
lrwxrwxrwx 1 root Sep  4 17:54/var/mail-> spool/ Mail
# You should know why you see here. Because the/var/mail is a link, link to/var/spool/mail 
# So, with the PWD-P option, it will not be displayed with the data of the link file, but the correct full path is displayed.
mkdir (Create new directory)
[Root@www ~]# mkdir [-mp] Directory name
options and Parameters:-
m: Configuration file Permissions Oh. Direct configuration, do not need to see the default permissions (umask) of the face ~-
p: To help you directly to the desired directory (including the previous level of the directory) back to create.
Example: Please try to create a few new directories below///
/. [Root@www ~]# cd/tmp
[root@www tmp]# mkdir test    <== Create a new directory for Test
[root@www tmp]# mkdir test1/test2/test 3/TEST4
mkdir:cannot Create directory ' test1/test2/test3/test4 ': 
No such file or directory       <== No way to create this directory directly AH.
[root@www tmp]# mkdir-p test1/test2/test3/test4
# Adds this-p option to help you create a multi-tiered directory yourself.
Example: Create a directory
with permissions of Rwx--x--x [Root@www tmp]# mkdir-m 711 test2
[root@www tmp]# ls-l
drwxr-xr-x  3 root  root 4096 June-12:50 test
drwxr-xr-x  3 root  4096 June 12:53 test1
drwx--x--x  2 root  root 4096 June 12:54 tes T2
# Take a closer look at the permissions section above, if you do not add-m to enforce configuration properties, the system uses default properties.
# So what's your default attribute? This will be through the umask introduced below to understand OH. ^_^
RmDir (delete "Empty" directory)
[Root@www ~]# RmDir [-p] Directory name
options and Parameters:-
P: Together with the "empty" directory above, delete the
example: the directory created in the mkdir example (/tmp) is deleted.
[root@www tmp]# ls-l   <== See how many directories exist.
drwxr-xr-x  3 root  4096 June 12:50 test
drwxr-xr-x  3 root  root 4096 June 12:53 Test1
  drwx--x--x  2 root  root 4096 12:54 test2
[root@www tmp]# rmdir test   <== can be deleted directly, no problem
[ Root@www tmp]# rmdir test1  <== cannot be deleted because there is still content.
rmdir: ' test1 ': Directory not empty
[Root@www tmp]# rmdir-p test1/test2/test3/test4 root@www tmp]# ls-l        You look at the bottom of the output, test and <== are missing.
drwx--x--x  2 root  root 4096 12:54 test2
# see. With-p This option, you can immediately delete Test1/test2/test3/test4 ~
# But note that this rmdir only "delete empty directory" Oh.
View of file and directory management files and directories: LS
[Root@www ~]# ls [-aadffhilnrrst] directory name [root@www ~]# ls [--color={never,auto,always}] Directory name [root@www ~]# ls [--full-time] Directory name options and parameters:-A: All files, along with hidden files (the file at the beginning of.) are listed together (common)-A: All files, along with hidden documents, but not included. And.. Both directories-D: Lists only the directory itself, not the file data in the directory (commonly used)-F: Lists the results directly without sorting (LS defaults to the file name). )-F: Based on documents, directory and other information, to give additional data structure, such as: *: representative of the executable file;/: representative Directory; =: represents the socket file; |: Represents the FIFO file;-H: Lists the file capacity in a more readable manner (such as GB, KB, and so on); List the inode number, the meaning of the Inode the next chapter will be introduced;-L: Long data strings are listed, including the attributes and permissions of the file, and so on; (common)-N: Lists the UID and GID names (UID and GID are mentioned in account management).
-R: Reverses the sort result, for example: the original file name from small to large, the reverse is from large to small;-R: Together with the subdirectory contents, all the files in the directory are displayed;-S: sorted by file size rather than filename; t: sorted by time, not file name. --color=never: Do not give the color display according to the file characteristics;--color=always: Display color--color=auto: Let the system determine by its own configuration whether to give color--full-time: In full time mode (including year, month, day, time , sub) Output--time={atime,ctime}: Output access time or Change permission attribute time (CTime) rather than content change time (modification)
CP (copy file or directory)
ROOT@WWW ~]# CP [-ADFILPRSU] source file (source) target file (destination) [Root@www ~]# CP [options] source1 source2 ... source3 Ry Options and Parameters:-A: Rather than the meaning of-pdr, as for PDR please refer to the following instructions; (Common)-D: If the source file is a link file property, copy the link property instead of the file itself;-F: for coercion (force), if the target files already exist and none Method is opened, then try again after the removal;-I: If the target file (destination) already exists, it will ask for the action (commonly used) in the overwrite (common)-l: Create a link file for a hard link (hard link) instead of copying the file itself; P: Copies the past along with the file's properties, Instead of using default properties (commonly used for backup); R: Recursive continuous replication, used for directory replication behavior; (common)-S: Copy to symbol link (symbolic link), or "shortcut" file; 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.