Linux Knowledge Collation

Source: Internet
Author: User
Tags bz2 unpack

NIT 0 Restart

Exit exits

LS Displays the current directory contents ls-a All files that contain hidden files under the display list ls-i display file details information, file properties, size, name

WHOAMI Display This user information who displays currently logged in user information

Date Current date Cal view specified date

Clear Clear

Useradd Create user passwd Modify user password

SU Switch User

Man View Linux instructions help get instructions help

mkdir Create a single directory mkdir-p create multiple directories at once touch create a file

RM Delete file rm-i Delete rm-r Delete directory rm-f Force Delete RM-RF Force delete everything

CP Copy file cp-r copy directory Cp-i ask whether to overwrite the original file cp-p with the file attributes copy cp-f Force copy

Bin System Instruction Directory sbin important system directory

PWD Displays the current directory

CD Switch Directory CD: Go back to the previous directory CD-go back to the previous directory CD ~ Go to the user home directory

MV Change Path

Cat View File Contents Head view file at the beginning of the 10 lines of content Head-n view the first n rows of the file

Tail viewing the last 10 rows of a file tail-n viewing the last n rows of a file more browse files

Users, groups, and permissions
1) New user natasha,uid is 1000,gid to 555, note information is "master"

Useradd nashata usermod-u1000 usermod-g555 usermod-c Master

2) Modify Natasha user's home directory for/natasha

Usermod-d/natasha Natasha

3) View the last line of the user information profile

Tail-1/etc/passwd
4) Set the password "123" for the Natasha user

PASSWD Natasha 123
5) View the last line of the user's password profile

Under the ETC Directory Tail-1 shadow
6) Lock the Natasha user account

USERMOD-L Natasha
7) Unlock the Natasha user account

Usermod-u Natasha

8) New group Police,gid to 999

GROUPADD-G 999 Police
9) View the last line of the group configuration file

Tail-1/etc/group
10) Add Natasha user to police group

Usermod-ag Police Natasha
11) Modify the group name of the police group to Jingcha

Groupmod-n Jingcha Police
12) Delete Natasha user, even home directory and mailbox deleted together

USERDEL-R Natasha

13) Delete Jingcha Group

Groupdel Jingcha





Two. In-depth discussion of users, groups and permissions
1) Create a directory test in the user's home directory, enter test to create an empty file File1

mkdir test, Cd/tast/touch file1
2) display file information in long format, note the permissions of the file and the user and group to which it belongs

ll File1-rw-r--r--. 1 root root 0 November 18:04 file1
3) Set permissions for file File1 so that other users can write to this file

chmod o+w File1
4) View the setting results,

ll file1-rw-r--rw-. 1 root root 0 November 18:04 file1
5) Remove the Read permission from the same group of users to the file File1 and view the setting results.

chmod g-r FILE1-RW----rw-. 1 root root 0 November 18:04 file1
6) Use digital notation to set permissions for file files, all readable, writable, and executable, and the owning group user and other users have only read and execute permissions. Review the setup results when the settings are complete.

chmod 755 File1-rwxr-xr-x. 1 root root 0 November 18:04 file1
7) Change the permissions of the file File1 in digital form so that the owner can only read the file. No other user has permission. View the settings results.

chmod file1-r--------. 1 root root 0 November 18:04 file1
8) go back to the upper directory to see the test permissions

Cd.. ll Test-rwxr-xr-x. 1 root root 0 November 18:04 file1
9) Add write permissions to this directory for other users

chmod o+w Test
Text processing commands and TAR commands
1) Merge user information database files and group information database files vertically into one file/1.txt (overwrite)

Cat/etc/passwd/etc/group > 1.txt

2) Merge user information database files and user password database files vertically into one file/2.txt (append)

Cat/etc/passwd/etc/shadow >> 2.txt
3) Package The/1.txt,/2.txt two files as a/1.tar

TAR-CF 1.tar 1.txt 2.txt
4) Use the gzip command to compress the 1.txt file named 1.txt.gz

Gzip 1.txt
5) Decompression 1.txt.gz

Gunzip 1.txt.gz
6) file name 1.txt.bz2 after compressing 1.txt compression with bzip2

Bzip2 1.txt
7) Decompression 1.txt.bz2

BUNZIP2 1.txt.bz2
8) Unpack 1.tar, unpack the file and store it in the/tmp directory

TAR-XF 1.tar-c/tmp
9) Use the TAR command to package and compress/1.txt,/2.txt, and get the file name 1.tar.gz

Tar-czf 1.tar.gz 1.txt 2.txt
10) Unpack the 1.tar.gz, unpack the file and store it in the/tmp directory

TAR-XF 1.tar.gz-c/tmp





Four. Create and edit body files using the VI Editor


1) Edit the file using the VI editor/1.txt Enter the edit mode to write the content "Hello World"

Vi/1.txt Enter the file and press A to enter edit mode, enter "Hello World"
2) Enter command line mode to copy the contents of the line, paste 80 lines below

Press ESC to enter command line mode, yy copy row, 80p paste 80 lines below.
3) quickly move the cursor to the last line of the file

G Move to last line
4) quickly move the cursor to the middle line of the current screen

M moves to the middle row
5) quickly move the cursor to the fifth line of the file

5G move to line fifth
6) Insert a new line below "Welcome to Beijing"

Press A to enter edit mode and enter "Welcome to Beijing" below
7) Delete the row you just inserted

Move the cursor to the line, DD deletes the row
8) Undo the previous step

U Undo Previous Action
9) Enter the extended mode to execute the file save exit

: Enter extension mode, input Wq save exit





Five. Initialization and service of the system


1) Log in to the system as the root user

Enter the root username and password to login
2) Modify the Grub configuration file, start with the 1th operating system by default, and change the default read second to 10 seconds

vim/etc/grub.conf default=0 timeout=10
3) Set Grub menu ciphertext password "123"

by Grub-md5-crypt get 123 ciphertext password, vim/etc/grub.conf in the title on a line to insert password--MD5 + obtained ciphertext password
4) Modify the default operating level of the system to 3

Vim/etc/inittab the bottom ID: After the number is changed to 3
5) Restart the system with commands related to the RunLevel

Init 6
6) Use single-user mode to modify the user's password to "123"

Read the second interface Press any key to enter, p input grub password, e into the next item, select the second kernel press E to enter the next item by the <HGB quiet after entering 1 back to the car after you press B to run into single user mode, passwd modify the user password
7) Remove Grub menu password using rescue mode







Six. System monitoring


1) Real-time dynamic monitoring System Status

Top
2) exit the previous step

Q
3) Turn on the top process

Open top on another terminal
4) Use the PS command to view the top command's PID and kill

PS aux |grep ' top ' |grep-v ' grep ' pid=4121 kill 4121
5) View process tree for process with PID 2

Pstree 2

6) Open Firefox browser

Firefox
7) Look for a process named Firefox

PS aux |grep ' firefox ' |grep-v ' grep ' pid=4009
8) Kill the process called Firefox

Kill 4009
Hard disk partitioning, formatting, and file system management one


1) Add a 20G SCSI hard disk before opening the Linux system

Edit Virtual machine Settings---> Add hard drives---> select SCSI, set the size to 20G
2) Turn on the system, right click on the desktop, open the terminal

Turn on the system, right click on the desktop, open terminal
3) for the newly added hard disk partition, a primary partition size of 10G, the remaining space to the extended partition, on the extended partition divided two logical partitions, the size of each 5G

Fdisk/dev/sdb-->n-->p (primary partition)-->1 (partition number)--Carriage return-->+10g (partition size)

N-->e (Extended partition)-->2--> Enter and enter (default to select all remaining space on the hard drive)

N-->l (Partitioning logical partitions on extended partitions)--Enter-->+5g (partition size)

N-->L (partition logical partitions on the extended partition)--Enter-and-Enter (default to select all remaining space for the extended partition)
4) format primary partition as EXT3 system

Mkfs.ext3/dev/sdb1
5) format two logical partitions for EXT4 system

MKFS.EXT4/DEV/SDB5 MKFS.EXT4/DEV/SDB6

Linux Knowledge Collation

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.