Linux second job

chapter02 - 03 jobs

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

View the entire contents of the file: cat

tac: reverse displays the entire contents of the file

nl: Display blank lines except line number

2, respectively, view the contents of / etc / ssh / sshd_config inside with more and less, please use the same summary and differences between more and less two commands?

Same: Full page display file contents, you can flip

Different: more can page down, less not only can be paged can also find the file contents

3, the first 20-line redirection save / etc / passwd file to / renamed 20_pass.txt the root, save the / etc / passwd file redirected to 15 rows / renamed as the root: pass_15.txt

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

[root@localhost ~]# cat /root/20_pass.txt | wc -l

20

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

[root@localhost ~]# cat /root/pass_15.txt | wc -l

15

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

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

2 /etc/hosts

[root@localhost ~]# du -s /etc/hosts

4       /etc/hosts

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

10 /etc/hosts

5, practice using grep and egrep

5.1. Filter through a pipe grep tool ifconfig command displays the IP field information?

[root@localhost ~]# ifconfig | grep "inet*"

        inet 192.168.100.121  netmask 255.255.255.0  broadcast 192.168.100.255

        inet6 fe80::41f3:baac:619d:ba29  prefixlen 64  scopeid 0x20<link>

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

5.2. Save the / etc / passwd file in the first 20 rows redirected to the / root under the name pass?

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

[root@localhost ~]# wc -l /root/pass

20 /root/pass

5.3. Filter / etc / passwd file contains a number of statistics rows and / sbin / nologin line?

[root@localhost ~]# grep "/sbin/nologin" /etc/passwd | wc -l

36

5.4 Filter / etc / passwd file ending in sh lines, and lines beginning with root, do not show the line containing the login?

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

root:x:0:0:root:/root:/bin/bash

5.5 were filtered with grep and egrep the / etc / ssh / sshd_config file does not contain the beginning of the '#' and blank lines?

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

Host *

         GSSAPIAuthentication yes

         ForwardX11Trusted yes

         SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES

         SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT

         SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE

         SendEnv XMODIFIERS

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

HostKey /etc/ssh/ssh_host_rsa_key

HostKey /etc/ssh/ssh_host_ecdsa_key

HostKey /etc/ssh/ssh_host_ed25519_key

SyslogFacility AUTHPRIV

AuthorizedKeysFile  .ssh/authorized_keys

PasswordAuthentication yes

ChallengeResponseAuthentication no

GSSAPIAuthentication yes

GSSAPICleanupCredentials no

UsePAM yes

X11Forwarding yes

AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES

AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT

AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE

AcceptEnv XMODIFIERS

Subsystem        sftp  /usr/libexec/openssh/sftp-server

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

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

tar: Removing leading names from members of the "/"

[root@localhost ~]# ls /root/

20_pass.txt anaconda-ks.cfg file.tar.gz initial-setup-ks.cfg pass pass_15.txt z public document template download music video pictures Desktop

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

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

tar: Removing leading names from members of the "/"

[root@localhost ~]# ls /root/

20_pass.txt anaconda-ks.cfg file.tar.bz2 file.tar.gz initial-setup-ks.cfg pass pass_15.txt z public document template download music video pictures Desktop

6.3 create an empty folder / web / test1, and file.tar.bz2 unpacked and release to the next / web / test1 directory?

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

mkdir: directory has been created "/ web / test1"

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

[root@localhost ~]# ls /web/test1/

etc

7.1 by the vi editor / web / test1 / passwd file will replace all benet file to root words.

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

:% s/root/benet/g

:wq

7.2 Edit Delete files pass through the first line 1,5,10 vi.

[root@localhost ~]#vi /root/pass

: Not set

dd1

F5

DD10

:wq

7.3 shows a file copy pass line numbers 234 attached to the lower rows beginning with the row in vi lp.

[root@localhost ~]#vi /root/pass

: Not set

3yy

P

:wq

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

[root@localhost ~]#vi /root/pass

: Not set

/ Mail was

7.5 the second row vi editor to quickly jump to the file, read the contents of / etc / hosts file to the second row by r.

[root@localhost ~]#vi /root/pass

: Not set

2G

:r /etc/hosts

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

:w /root/new_pass

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

[root@localhost ~]# gzip /root/new_pass

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

[root@localhost ~]# ls /root/npass.gz

/root/npass.gz

The number of files in the 8 statistics / dev directory.

[root@localhost ~]# ls -l /dev | wc -l

158

9.1 Find filename begins with vmlinuz files in the / boot?

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

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

/boot/vmlinuz-0-rescue-6c0f6e59a17540769f4a75871c16d348

9.2 Find File size is greater than 3M less than 20M in the / boot

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

/boot/System.map-3.10.0-693.el7.x86_64

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

/boot/vmlinuz-0-rescue-6c0f6e59a17540769f4a75871c16d348

/boot/initrd-plymouth.img

10 Follow the steps to build a local yum repository of detailed write? And in command after each line cook Chinese comments in your own words?

umount / media / // unload the disc / media / mounted under the

ls / media /

mount / dev / sr0 / media / // will mount the first CD under / media / directory

ls / media /

cd /etc/yum.r*

mkdir a/

mv C* a/

Create a local yum repository document

we ./local.repo

[Cdrom] // names warehouse

name=cdrom

baseurl = file: /// media // specified location rpm package

enabled = 1 // enable local yum repository

Disable gpgcheck = 0 // check gpg

----------------

Clear Cache yum

yum -y clean all

Reconstruction yum cache

yum makecache

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

[root@localhost ~]# rpm -q vsftpd

Vsftpd package is not installed

[root@localhost ~]# umount /dev/sr0

[root@localhost ~]# mount /dev/sr0 /media/

mount: / dev / sr0 write protection, will be mounted read-only

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# mkdir a

[root@localhost yum.repos.d]# mv C* a

[root@localhost yum.repos.d]# vi cdrom.repo

[root@localhost yum.repos.d]# yum -y clean all

Loaded plugins: fastestmirror, langpacks

Is cleaning up the software source: cdrom

Cleaning up everything

Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos

Cleaning up list of fastest mirrors

[root@localhost yum.repos.d]# yum makecache

Loaded plugins: fastestmirror, langpacks

cdrom                                                                                                                                                 | 3.6 kB  00:00:00    

(1/4): cdrom/group_gz                                                                                                                                 | 156 kB  00:00:00    

(2/4): cdrom/filelists_db                                                                                                                             | 6.7 MB  00:00:00    

(3/4): cdrom/primary_db                                                                                                                               | 5.7 MB  00:00:00    

(4/4): cdrom/other_db                                                                                                                                 | 2.5 MB  00:00:00    

Determining fastest mirrors

Metadata cache has been established

[root@localhost yum.repos.d]# yum -y install vsftpd

[root@localhost ~]# rpm -q vsftpd

vsftpd-3.0.2-22.el7.x86_64

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

[root@localhost ~]# rpm -q vsftpd

Vsftpd package is not installed

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

[root@localhost ~]# rpm -q vsftpd

Vsftpd package is not installed

[root@localhost ~]# cd /media/Packages/

[root@localhost Packages]# rpm -iv vsftpd-3.0.2-22.el7.x86_64.rpm

Warning: vsftpd-3.0.2-22.el7.x86_64.rpm: header V3 RSA / SHA256 Signature, Key ID f4a80eb5: NOKEY

Packages in preparation ...

vsftpd-3.0.2-22.el7.x86_64

[root@localhost Packages]# rpm -q vsftpd

vsftpd-3.0.2-22.el7.x86_64

13, by way of unpacking by source, arranged, compiling, the step of mounting four source software install httpd-2.2.17.tar.gz? And tested?

[root@localhost httpd-2.2.17]# yum -y install gcc gcc-c++ make

The installation process will be omitted

[root@localhost ~]# tar -xf httpd-2.2.17.tar.gz -C  /usr/src

[root@localhost ~]# cd /usr/src/httpd-2.2.17/

[root@localhost httpd-2.2.17]# ./configure –prefix=/usr/local/apache

Mentioned here

[root@localhost httpd-2.2.17]#make

Mentioned here

[root@localhost httpd-2.2.17]#make install

Mentioned here

[root@localhost httpd-2.2.17]# cd /usr/local/apache/conf/

[root@localhost conf]# cp httpd.conf httpd.conf.bak

[root@localhost conf]# vi /usr/local/apache/conf/httpd.conf

Content: 97 to remove the line number #

[root@localhost conf]#yum –y install lynx

Mentioned here

[root@localhost conf]#lynx 127.0.0.1

Guess you like

Origin www.cnblogs.com/zhiyuan-yu/p/11248105.html