Linux knowledge finishing

nit 0 Restart 

exit Exit

ls Display the contents of the current directory ls -a Display all files in the list including hidden files ls -i Display file details, file attributes, size, name

whoami Display this user information who Display currently logged in user information

date Current Date cal View the specified date

clear Clear

useradd Create user passwd Change user password

su Switch user

man View Linux command help help Get command help

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

rm Delete a file rm -i Ask before deletion 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 original file cp -p copy together with file attributes cp -f force copy

bin system command directory sbin Important system directory

pwd Display the current directory

cd Change directory cd .. Return to the previous directory cd - Return to the last directory cd ~ Enter the user's home directory

mv Change the path

cat View the file content head View the first 10 lines of the file head -n View the first n lines of the file

tail View the last 10 lines of the file tail -n View the last n lines of the file more Browse the file

Users, groups and permissions
1) Create a new user natasha, uid is 1000, gid is 555, and the remark information is "master"

useradd nashata usermod -u1000 usermod -g555 usermod -c master

2) Modify the home directory of the natasha user to /Natasha

usermod -d/Natasha natasha

3) View the last line of the user information configuration file

tail -1 /etc/passwd
4) Set the password "123" for the natasha user

passwd natasha 123
5) View the last line of the user password configuration file

tail in the etc directory -1 shadow
6) Lock natasha user account

usermod -L natasha
7) Unlock natasha user account

usermod -U natasha

8) Create a new group police, gid is 999

groupadd -g 999 police
9) View the last line of the group configuration file

tail - 1 /etc/group
10) Add the natasha user to the police group

usermod -aG police natasha
11) Modify the group name of the police group jingcha

groupmod -n jingcha police 12) Delete the natasha user, delete userdel -r natasha
together with the home directory and mailbox 13) Delete the jingcha group groupdel jingcha II. 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 the file information in long format, pay attention to the permissions of the file and the user and group to which it belongs ll file1 -rw -r--r--. 1 root root 0 November 11 18:04 file1 3) Set permissions for the file file1, so that other users can write to this file chmod o+w file1 4) Check the setting result, ll file1 -rw-r--rw-. 1 root root 0 November 11 18:04 file1 5) Cancel the read permission of the same group of users to the file file1, and check the setting result. chmod gr file1 -rw----rw-.1 root root 0 Nov 11 18:04 file1



























6) Use digital notation to set permissions for the file file, the owner is readable, writable, and executable, and the group users and other users have only read and execute permissions. Check the setting result after the setting is complete.

chmod 755 file1 -rwxr-xr-x. 1 root root 0 Nov 11 18:04 file1
7) Numerically change the permissions of file file1 so that the owner can only read this file. No other user has permission. View the setting result.

chmod 400 file1 -r--------. 1 root root 0 November 11 18:04 file1
8) Go back to the upper directory and check the permissions of test

cd .. ll test -rwxr-xr-x. 1 root root 0 November 11 18:04 file1
9) Add write permission to this directory for other users

chmod o+w test
text processing command and tar command
1) Combine the user information database file and group information database file vertically into one file / 1.txt (overwrite)

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

2) Vertically merge the user information database file and the user password database file into one file /2.txt (append)

cat /etc/passwd /etc /shadow >> 2.txt
3) Package the two files /1.txt and /2.txt into /1.tar

tar -cf 1.tar 1.txt 2.txt
4) Use gzip command to compress 1.txt file name 1.txt.gz

gzip 1.txt
5) Uncompress 1.txt.gz

gunzip 1.txt.gz
6) Use bzip2 compress 1.txt file name after compression 1 .txt.bz2

bzip2 1.txt
7) Unzip 1.txt.bz2

bunzip2 1.txt.bz2
8) Unpack 1.tar, and store the unpacked file in the /tmp directory

tar -xf 1.tar -C/ tmp
9) Use the tar command to pack and compress /1.txt, /2.txt, and the resulting file name is 1.tar.gz

tar -czf 1.tar.gz 1.txt 2.txt
10) Unpack 1.tar .gz, after unpacking, the files are stored in the /tmp directory

tar -xf 1.tar.gz -C/tmp





4. Use vi editor to create and edit text files


1) Use vi editor to edit the file/1.txt to enter editing Mode write content "hello world"

vi /1.txt After entering the file, press a to enter edit mode, enter "hello world"
2) Enter command line mode to copy the content of the line, paste line 80 below and

press esc to enter command line mode, yy copy and change line, 80p paste 80 lines below.
3) Quickly move the cursor to the last line of the file

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

M to the middle line
5) Quickly move the cursor to the fifth line of the file

5G move to the fifth line
6) Insert a new line below "welcome to beijing"

Press a to enter the editing mode Enter "welcome to beijing" below
7) Delete the line just inserted

Move the cursor to the line, dd delete the line
8) Cancel the previous operation

u Cancel the previous operation
9) Enter the extension mode, save the file and exit

: Enter extended mode, input wq to





save


and exit For 10 seconds vim /etc/grub.conf default=0 timeout=10 3) Set the grub menu cipher text password "123" to get the cipher text password of 123 through grub-md5-crypt, vim /etc/grub.conf is on the title Insert a line of password --md5 + the ciphertext password obtained 4) Modify the default run level of the system to 3 vim /etc/inittab Change the number after the bottom id: to 3 5) Use the command related to the run level to restart the system init 6














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

, press any key to enter the countdown interface, p enter the grub password, e enter the next item, select the second kernel, press e to enter the next item, and press space after <hgb quiet Enter 1 and press b to run to enter single-user mode, passwd to modify the user password 7 ) Use rescue mode to delete the grub
menu password Process Open top in another terminal 4) Use the ps command to view the pid of the top command and kill ps aux |grep 'top'|grep -v 'grep' pid=4121 kill 4121 5) View the process tree of the process whose pid is 2 pstree 2 6) Open firefox browser firefox 7) Find the process named firefox ps aux |grep 'firefox'|grep -v 'grep' pid=4009 8) Kill the process named firefox kill 4009 hard disk partition, format and file system management 1) Add a 20G SCSI hard disk before starting the Linux system Edit virtual machine settings--->Add hard disk--->Select SCSI, set the size to 20G 2) Start the system, right-click the desktop, and open the terminal











































Start the system, right-click on the desktop, and open the terminal
3) For the newly added hard disk partition, the size of one primary partition is 10G, the remaining space is for the extended partition, and two logical partitions are divided on the extended partition, each with a size of 5G

fdisk /dev/sdb- ->n-->p (primary partition)-->1 (partition number)-->Enter -->+10G (partition size)

n-->e (extended partition)-->2-->return Car --> Enter (select all the remaining space of the hard disk by default)

n-->l (divide logical partitions on the extended partition) --> Enter -->+5G (partition size)

n-->l ( Divide the logical partition on the extended partition)-->Enter-->Enter (all the remaining space of the extended partition is selected by default)
4) Format the primary partition as ext3 system

mkfs.ext3 /dev/sdb1
5) Format two The logical partitions are ext4 system

mkfs.ext4 /dev/sdb5 mkfs.ext4 /dev/sdb6

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325388271&siteId=291194637