linux-ubuntu-Study the third article

Source: Internet
Author: User
Tags bz2 rar readable time and date cpu usage disk usage

20. Create a new user forget to use the-M option, will not create a new user's directory in the home directory, the simplest way is to use Userdel Delete new user re-create, no directory Although veteran can operate, but the time is long, you do not remember what files inside, resulting in difficult operation;/etc/ The passwd file holds the user information, consisting of 6 semicolons and 7 messages. are: 1 User Name 2 password (x. For encrypted password) 3UID4GID5 user's full name or local account 6 Home 7 login using the shell, is the terminal command used after login, ubuntu default (other users) using dash, the main user is the use of bash, the difference is the shell inside the fast Czech command and command display differences, such as display information color differences, shortcut commands can not be used, etc., need to use the sudo usermod-s/bin/bash user name with the above command to achieve the change between dash and bash, easy to manage and differentiate (increase/bin/ Bash's absolute path), note: After re-login takes effect.
21.usermod, can be used to set the user's primary group/additional group and login shell, the command format is as follows:
Primary Group: A group that is typically specified when a new user is created, and the fourth column of the GID in etc/passwd.
Additional groups: The last column in Etc/group represents the list of users for this group, which specifies additional permissions for the user, and after you set up the user's additional group, you need to log back in to take effect. Note: Users added by default with Useradd are not authorized to use sudo to execute commands as root, and users can be added to the sudo add-in group using the following command: Usermod-g sudo username, note: Re-login will take effect.
22.linux Most of the executables are stored in the/bin,/sbin,/usr/bin,/usr/sbin file, bin (binary) is a binary executable directory, mainly for specific applications, sbin (System Binary) is a system administrator-specific binary code storage directory, mainly used for system management,/usr/bin (user commands for Applications) post-installation of some software;/usr/sbin/(Super User commands For applications) Some management programs for super users; CD This command is built into the system kernel (and the system code is written together), there is no independent file, so with which is unable to find the location of the CD, others can.
23.SU switching users, the concept of Linux and Unix are familiar to everyone, not playing it does not matter, Windows inside the guest and the system you understand the same. Under different users to do different operations, the purpose is only for group management, does not affect the operation of each other, switching mode is relatively simple: su+ user name, to the directory also switch with Su-user name can be; Note: The new user must have a password, in addition to the new user under the operation of enter exit is logged off, Direct switch back to the home directory of the main user, after Su does not take the user name, directly into the root, the operation in root does not require the sudo command, this operation is very dangerous, so it is not recommended to use, in addition to the new device is best to set up in advance without the associated root password, If you do not set a password, you can only be trampled after someone has set the root password, unless you re-install the system, so the loss is huge.
24. The command to view the status of the system has date, cal-y, df-h, du-h, PS aux, top, kill, etc. using the KILL command, it is best to terminate the current user's process only, rather than terminating the process that root is open, which could cause the system to crash To exit top you can exit directly with the lowercase letter Q.
25.linux files and file data is stored separately, hard links and soft links can be described in detail in the circumstances, I personally understand: soft link-absolute path corresponding to the file, hard link-a copy of the file; In Linux, only the number of hard links in the file = 0, the file will be deleted, using LS- L can see the number of hard links in a file, the general work will not establish a hard link, understand the principle can be.
26. Packaging and compressing this piece, Linux and RAR in Windows and the zip in the Mac is a little different, Linux is Tar.gz;tar is the most common Linux Backup tool, this command can be a series of files packaged into a file, You can also restore a large package of files to a series of small files to facilitate file transfer; The tar command uses the option C-Generate the archive file, create the package file, X-unlock the file, and V to list the detailed process of the archive file, show the progress; F-Specify the profile name, f must be a. tar file behind it, so you have to put the option behind it, the F option must be at the end, the other options can be arbitrary, and the terminal uses the command TAR-CVF to package the file. Tar is packaged by a packaged file/path and packaged with TAR-XVF. Tar to unpack the package , tar and gzip in combination with the implementation of file packaging and compression, Linux, the common compressed file format is: xxx.tar.gz, in the tar command has an option-Z can call gzip, which can be conveniently implemented compression and decompression functions.
Installation package management tools in 27.linux apt (Advanced Packaging tool) can install/uninstall/update packages conveniently in terminal, install software sudo apt install package name; Uninstall software: sudo apt remove software name ; Update the installed package, sudo apt upgrade.
28.linux software Source is the main server, in foreign countries, but he will have a lot of mirror source, these are in the domestic, the image source above the software and the foreign master server above the software is consistent; We download the software can be set up the image source to select one of the fastest server to download/install software services.
Create a new user
Useradd-m-G Group New user name add new user "-M automatically create a new user directory
-g Specifies the group for the new user, or a group with the same name will be created
passwd User Name set user password if it is a normal user, with password directly modify it can
sudo useradd-m-G dev Wen add wen user with dev Group directory
sudo passwd wen set user password, enter to write
Userdel-r User Name-R automatically delete user home directory
cat/etc/passwd | grep user name when a new user is created, the user information is automatically saved in the/etc/passwd file
View user Information
ID Username "Displays user information with UID and GID
User ID and group ID "
"Verify: Cat-n/etc/passwd | grep Wen
Cat-n/etc/group | grep wen "User ID and group ID are saved in/etc/passwd and/etc/group files, respectively
Who view current list of all logged in users
WhoAmI can view other user login information to view the account name of the currently logged in user
Usermod for modifying the user's primary group, additional groups, shell
USERMOD-G group user name Modify primary Group
USERMOD-G Group user name modify additional groups
Usermod-s/bin/bash Modifying the shell
Eg:sudo usermod-g sudo wen authentication: cat-n/etc/group | grep wen Add the sudo add-on group to the Wen user under the primary user, note: Re-login to take effect
Shell Input Terminal Command window
Eg:sudo usermod-s/bin/bash wen changes the Wen Shell to Bash's shell, which includes features such as user, user name, machine name, shortcut command, file display features, and more.
which to see where the execution command is located
/etc/passwd file that holds user information is a text file
/USR/BIN/PASSWD The program used to modify the user's password is the program saved under/USR/BIN/PASSWD
Which passwd view password stored path, just text information, cannot execute
Ls-l/USR/BIN/PASSWD View the file information that holds the password, the path contains rwx, the path is displayed in red, indicating the executable
Which useradd display path is/usr/sbin/useradd
Ls-l/usr/sbin/useradd
SU Switch User
Modify file Permissions
Chown Change owner Modify owner
CHGRP Change Group
chmod Change Mode Modify Permissions
Eg:chown owner user name File name | directory name
EG:CHGRP-R group name File/directory name
sudo chown wen 56.py/modify Tom User's files under 56.py files for Wen users
sudo chown wen/home/python/desktop/56.py
CHOMD Digital notation CHOMD When setting permissions, you can simply use three numbers to represent the respective owner/group and other users ' permissions
CHOMD +/-rwx file name | directory name
Owner Group Other
"R---------4 readable permissions
W---------2 writable permissions
X----------1 Executable permission "" R---------4 readable permission
W---------2 writable permissions
X----------1 Executable permission "" R---------4 readable permission
W---------2 writable permissions
X----------1 Executable Permissions "
"4+2+1=7 Readable and writable
4+2+0=6 can be read and writable
4+0+1=5 readable executable not writable
0+2+1=3 executable cannot be read and not writable
0+2+0=2 writable, unreadable and not executable
0+0+1 executable, unreadable non-writable "" U Owner
Group G
0 other users "" 4+2+1=7 readable writable
4+2+0=6 can be read and writable
4+0+1=5 readable executable not writable
0+2+1=3 executable cannot be read and not writable
0+2+0=2 writable, unreadable and not executable
0+0+1 executable, non-readable and non-writable "
Eg:chmod-r 755 file name | directory name-r recursive Modify permission
chmod 754 56.py
chmod 640 123.txt
Chmod-r 775 Test Modify Test Directory
System Information Related commands
Time and date "date"
Cal------Calender Calendar "
Disk and directory Space "DF
Du
Process Information "PS
Top
Kill "process status to view the details of the progress
CST viewable as standard Time Central Standard time for the United States, Australia, Cuba or China
Cal-y View one year calendar
DF Disk free shows disk space remaining
Du disk usage Displays the file size under the directory
Df-h-H displays file sizes in a humane way
du-h [directory name] does not receive directory name to view the current directory-------to display the file size in a humane way
Process information process refers to a program that is currently executing
PS aux PS default only shows the application that the current user launched through the terminal "a displays all processes on the terminal, including other users ' processes
U Show detailed status of the process
X shows no control of the terminal process "
Top
Main parameters
D: Specifies the interval of the update, in seconds.
Q: There are no delayed updates. If the user has a superuser, the top command will be executed with the highest precedence.
C: Displays the full path and name of the process.
S: Cumulative mode, which accumulates the CPU time of a child stroke that has completed or disappeared.
S: Safe mode.
I: Do not display any idle (idle) or useless (Zombie) travel.
N: Displays the number of updates, and will exit to when completed
Display parameters:
PID (Process ID): progress indicator number.
User: The username of the process owner.
PR: The priority level of the process.
NI: The value of the priority level of the process.
VIRT: The virtual memory value that the process occupies.
RES: The physical memory value that the process occupies.
SHR: Shared memory value used by the process.
S: The state of the process, where s indicates hibernation, R is running, Z represents a zombie state, and N indicates that the process precedence value is negative.
%CPU: The CPU usage that the process consumes.
%MEM: The percentage of physical memory and total memory that the process occupies.
Time+: The total CPU time that is consumed after the process is started.
Command: The start command name of the process startup, and if this line does not appear, the process will have a full command line.
Top command
"Space": immediately refresh.
P: Sort According to CPU usage size.
T: Sort by time, cumulative time.
Q: Exit the top command.
M: Toggles display memory information.
T: Toggles display of process and CPU status information.
C: Toggle display command name and full command line.
M: Sorts according to the size of the memory used.
W: Writes the current settings to the ~/.TOPRC file. This is the recommended way to write top configuration files.
The DF command is a Linux system that views the file system as a disk partition, which can be added with parameters to view the disk's remaining space information, command format:
Df-hl
The display format is:
File system??????? Capacity has been used with available% mount points
"Filesystem Size used Avail use% mounted on
/dev/hda2 45G 19G 24G 44%/
/DEV/HDA1 494M 19M 450M 4%/boot
/dev/hda6 4.9G 2.2G 2.5G 47%/Home
/dev/hda5 9.7G 2.9G 6.4G 31%/opt
None 1009M 0 1009M 0%/dev/shm
/dev/hda3 9.7G 7.2G 2.1G 78%/usr/local
/DEV/HDB2 75G 75G 0 100%/
/DEV/HDB2 75G 75G 0 100%/"
With the above output as an example, the meaning of the expression is:
The second hard drive interface (b), the second partition (2), the capacity is 75G, with 75G, usable is 0, so the utilization is 100%, is mounted to the root partition directory (/).
The following is an explanation of the relevant commands:
DF-HL Viewing disk space remaining
Df-h viewing the partition size for each root path
Du-sh [directory Name] Returns the size of the directory
DU-SM [Folder] Returns the total number of M in this folder
More functions you can enter the command to view:
DF--help
Du--help
To view the partition of a hard disk #sudo fdisk-l
View IDE Hard disk information #sudo hdparm-i/dev/hda
View stat hard Drive information #sudo hdparm-i/DEV/SDA or #sudo apt-get install blktool #sudo BLKTOOL/DEV/SDA ID
View hard disk remaining space #df-H #df-H
View Directory footprint #du-HS directory name
U disk cannot unload #sync fuser-km/media/usbdisk
Kill End Process
Kill PID (Process code)
Kill-9 PID-9 Enforcement
Other commands
The find Find command is very powerful and is typically used to search for files in a specific directory for eligible files
ln soft link, similar to a shortcut under Windows
Tar packaging and compression
Apt-get Software Installation
Find [path]-name "file name" if the default path means look under the current folder
The wildcard character that was previously learned. When using the Find command, "finds files with a. py extension under a specified path, including subdirectories
eg:find/home/wen/desktop/-name " 1"Find Wen user's desktop file that contains 1 of files
Find-name " txt
Ln-s is linked to the source file link file (the name of the shortcut) "No-s option is established for a hard-link file, a hard link is to create a file that occupies the same hard disk space size, similar to a copy, can be renamed
The source file to use absolute path, can not use relative path, so easy to move the linked file, still can use, in fact, that the address must be located from the home under "What directory to operate, then create a shortcut to save in what directory
Ln-s/home/wen/dev/56.py Xiangdui use ls-l to view relative path representations create 56.py soft links for Xiangdui
ln/home/wen/dev/56.py xiangdui-1 Create a hard link of 56.py for xiangdui-1
Package Compression "Windows-rar
Mac-zip
Linux-tar.gz "
TAR-CVF package file name. tar packaged files/paths package files
TAR-XVF package file. Tar unpacking file
Tar-c Generating the archive file, creating a packaged file
Tar-x Unlocking the archive file
TAR-V lists detailed procedures for archiving the files, showing progress
Tar-f Specify the file name, F must be a. tar file, so you have to put it in the last
Rm-r
-R can delete folders delete all files and folders
TAR-CVF Py.tar 123.txt A 366.txt package 123.txt a 366.txt three files into a Py.tar packaged file
TAR-XVF Py.tar Unpacking the Py.tar package file
TAR-ZCVF packaging files. tar.gz compressed file/path Compressed file
TAR-ZXVF packaging files. tar.gz Extract Files
TAR-ZXVF packaging files. Tar.gz-c directory path-C extract to the specified directory, note: The directory to be decompressed must be uncompressed to the specified path
TAR-ZCVF Py.tar.gz/home/wen/desktop/py.tar Wen User under Desktop file Py.tar compressed into py.tar.gz
mkdir GZ Create Gz folder
MV py.tar.gz GZ move py.tar.gz to GZ folder
TAR-ZXVF py.tar.gz Decompression py.tar.gz
Bzip2 2 pronunciation in bzip2 and gzip compression using the same method, change-Z to-j
TAR-JCVF packaging files. tar.bz2 compressed file/path Compressed file
TAR-JXVF packaging files. tar.bz2 Extract Files
TAR-JCVF py.tar.bz2 *.py to compress all py files into py.tar.bz2
TAR-JXVF py.tar.bz2-c bz2-c extracted to the specified path, note: The directory to be decompressed must be in a folder that extracts the compressed file py.tar.bz2 to the bz2
Software Installation via apt Install/uninstall software
sudo apt-get install SL installation locomotive tips
sudo apt-get install htop installation color display top information

linux-ubuntu-Study the third article

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.