Some basic Linux commands 2

1 , respectively, with the cat \ tac \ nl three commands to view the file / etc / ssh / sshd_config content files, and use your own words the difference between the total of these three documents operation command?

[root@localhost ~]# cat /etc/ssh/ssh_config

[root@localhost ~]# tac /etc/ssh/ssh_config

[root@localhost ~]# nl /etc/ssh/ssh_config

cat is a forward displaying content; TAC is reverse display content; NL is the number of display content and display line

2 , respectively, more and less view / etc / ssh / sshd_config contents inside, please summarize the more and less same and the differences between the two orders?

[root@localhost ~]# more /etc/ssh/ssh_config

[root@localhost ~]# less /etc/ssh/ssh_config

more in a shift + pgup / pgon to flip up and down

less with arrows ↑ ↓ flip lookup is n check under a N one

All the same page with a space Enter the next line

3 , the / etc / passwd before file 20 stored row redirected to / root renamed under 20_pass.txt, the / etc / passwd after file 15 stored row redirected to / root renamed as under: pass_15.txt

[root@localhost ~]# head -20 /etc/passwd >/root/20_pass.txt

[root@localhost ~]# tail -15 /etc/passwd >/root/pass_15.txt

4 , please use a statistical command / etc / hosts file contains the number of firms? How many bytes? How many words count ?

[root@localhost ~]# wc /etc/hosts

5 , practice using grep and egrep

5.1. By grep filter out the plumbing tools ifconfig command to display the information in the IP field?

[root@localhost ~]# ifconfig | grep -o "[0-9]\{1,3\}\.[1-9]\{1,3\}\.[0-9]\{1,3\}\.[1-9]\{1,3\}" | head -1

5.2 The / etc / passwd file before the 20 -line redirection saved to the / root under the name Pass ?

[root@localhost ~]# head -20 /etc/passwd >/root/pass

5.3. Filter / etc / passwd file containing / sbin / nologin number of statistics rows and rows?

[root@localhost ~]# grep -c "/sbin/nologin" /etc/passwd

5.4 Filter / etc / passwd file to sh at the end of the line , and to root beginning of the line , do not show contains login line?

[root@localhost ~]# grep "sh$" /etc/passwd | grep "^root" | grep -v "login"

5.5 respectively grep and egrep filter out the / etc / ssh / sshd_config file does not contain " # beginning" and a blank line?

[root@localhost ~]# grep -v "#^" /etc/passwd | grep -v "^$"

[root@localhost ~]# egrep -v "^#|^$" /etc/ssh/sshd_config

6.1 by tar command to / etc / passwd file packaged as a compressed /root/file.tar.gz

[root@localhost ~]# tar -zcf /root/file.tar.gz /etc/passwd

6.2 by tar command to / etc / passwd file packaged as a compressed /root/file.tar.bz2

[root@localhost ~]# tar -jcf /root/file.tar.bz2 /etc/passwd

6.3 create an empty folder / web / test1 , and file.tar.bz2 unpacked and released into the / web / test1 directory?

[root@localhost ~]# mkdir -p /web/test1

[root@localhost ~]# tar -xf file.tar.bz2 -C /web/test1

7.1 by vi editor / web / test1 / passwd file file to root replace all words Benet .

[root@localhost ~]# vi /web/test1/etc/passwd

:% s/root/benet/g

7.2 by vi editor to delete pass Paper No. 1 , 5 , 10 rows.

:1 dd

:5 dd

:10 dd

7.3 In vi display pass line numbers copy document 234 rows pasted into lp the beginning of the line.

Cursor to 2 rows

3yy

/lp

p

7.4 by vi in the editing lookup file contains mail var like strings, and the recording line number.

: / Set no

:/mail   12,

: / Was 4,5,8,12,15,20,22,26,29,31,32,33,3536,39,38,40

7.5 By vi second line editing to quickly jump to a file by r read / etc / hosts content file to the second row.

:2

:r /etc/hosts

7.6 The changed files using vim Save as / root / new_pass .

:w  /root/new_pass

7.7 The new_pass files compressed into gz format and renamed npass.gz file.

[root@localhost ~]# gzip new_pass | mv new_pass.gz npass.gz

8 Statistics / dev number of files in the directory.

[root@localhost ~]# ls -l /dev/ | grep -v "^d" |wc -l

9.1 in / boot to find the file names under vmlinuz beginning of the file?

[root@localhost ~]# find /boot -name vmlinuz*

/boot/vmlinuz-3.10.0-229.el7.x86_64

/boot/vmlinuz-0-rescue-9a65ea9ec3044d628dc501909195e94f

9.2 in / boot to find the file size is greater than 3M less than 20M documents

[root@localhost ~]# find /boot -size +3M -a -size -20M

/boot/vmlinuz-3.10.0-229.el7.x86_64

/boot/vmlinuz-0-rescue-9a65ea9ec3044d628dc501909195e94f

/boot/initramfs-3.10.0-229.el7.x86_64.img

10 Please write the detailed construction of local yum steps warehouse? And in command after each line cook Chinese comments in your own words?

umount / media        launch mount the CD

mount / dev / sr0 / media mount the CD    

cd /etc/yum.b enter etc under yum.b ***   file     

mkdir a create a folder a          

mv C * a will be used in C for the opening are cut to a li           

vi local.repo create local.repo file and edit           

[cdrom] Name               

name = cdrom name             

baseurl = file: /// media to develop rpm package location        

enabled = 1 enable local yum repository             

gpgcheck = 0 Close gpg check              

yum -y clean all clear yum cache    

yum makecache reconstruction yum cache     

rpm -q vsftpd to see if the installed vsftpd package      

yum -y install vsftpd install vsftpd package        

rpm -q vsftpd View vsftpd package      

yum -y remove vsftpd unloading vsftpd package       

rpm -q vsftpd View vsftpd package        

 

11 , with the yum install command vsftpd, queries installation, and finally unload vsftpd , and query offload situation again?

[root@localhost Packages]# yum -y install vsftpd

[root@localhost Packages]# rpm -q vsftpd

[root@localhost Packages]# yum -y remove vsftpd

[root@localhost Packages]# rpm -q vsftpd

12 , with the rpm install command vsftpd, queries installation, and finally unload vsftpd , and query offload situation again?

[root@localhost Packages]# rpm -q vsftpd

[root@localhost Packages]# rpm -i vsftpd-3.0.2-9.el7.x86_64.rpm

[root@localhost Packages]# rpm -q vsftpd

[root@localhost Packages]# rpm -e vsftpd

[root@localhost Packages]# rpm -q vsftpd

Guess you like

Origin www.cnblogs.com/yuan9910/p/11250351.html