Linux system analysis head song experiment

For the Linux course of the University’s Go-8 program, you need to use the head song to complete the experiment and make a tutorial for everyone to learn from. It is strictly forbidden to copy and copy, and some can only be completed after understanding the meaning.

  1. The premise is that the minimum foundation is needed, and the text file can be edited. Just don't copy the wrong order.
  2. Maybe everyone’s Linux chapters are different. I will write what I have in my course first. If there are any differences, you can private message me and send me the steps. I will add it to this article. It is convenient for everyone.
  3. Since I wrote it myself (at least I sorted out the big questions later), there may be some omissions. Welcome to propose an improvement plan, and I will change it later.

Chapter 1 Introduction to Linux

1

cd /
ls -a

touch newfile
mkdir newdir
cp newfile newdir/newfileCpy

man 3 fopen

Chapter 2 Linux User Management

2
Linux user management

useradd -m newUser
userdel -r oldUser
cd /home/newUser
pwd

#!/bin/bash
#创建newUser新用户
#***********begin*************#
useradd newUser
#************end**************#
#在符号<<前输入设置用户密码的命令(命令与<< EOF保持在同一行), 密码输入在下一行,确认密码输入在下下行
#例如:
#command << EOF
#password
#password
#EOF
#***********begin*************#
passwd newUser << EOF
1
1
EOF
#************end**************#

#!/bin/bash
#创建newUser新用户
#***********begin*************#
useradd newUser
#************end**************#
#在符号<<前输入设置用户密码的命令(命令与<< EOF保持在同一行), 密码输入在下一行,确认密码输入在下下行
#例如:
#command << EOF
#password
#password
#EOF
#***********begin*************#
passwd newUser << EOF
1
1
EOF
#************end**************#
#使用su命令切换当前用户身份为newUser,并且执行whoami指令,然后恢复原来的身份;
#提示使用su命令的-c参数完成
#***********begin*************#
su -c whoami newUser
#************end**************#

Linux user advanced management

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
groupadd newGroup
groupadd -g 1010 newGroupID
groupdel oldGroup
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
useradd newUser
usermod -a -G oldGroup newUser
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
usermod -l newName oldName
usermod -d /home/newName newName
groupmod -n newGroup oldGroup
#************end**************#

Chapter 3 Linux Storage System

1
Linux hard disk management

A C

C ACD AC B

A	A	D	ABC

Chapter 4 Linux File/Directory Management

4

Linux file/directory management

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
touch file1
touch file2
rm oldFile1 oldFile2
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
mkdir newDir1 newDir2
rmdir oldDir1
rm -r oldDir2
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
cp file1 Dir
cp file2 Dir
cp file1 Dir/file1Cpy
mv file3 file4 Dir
mv file5 file6
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
cp -r Dir1 Dir2 Dir
cp -r Dir1 Dir/Dir1Cpy
mv Dir3 Dir4 Dir
mv Dir5 Dir6
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
cat file1
head -n 5 file2
tail -n 5 file2
ls -a /home
#************end**************#

Linux file/directory advanced management 1

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
chmod u=x oldFile1
chmod g-w oldFile2
chmod o+x oldFile3
chmod a=r oldFile4
chmod g=w oldFile4
chmod o=x oldFile4
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
chmod u=x oldDir1
chmod g-w oldDir2
chmod o+x oldDir3
chmod u=r,g=w,o=x oldDir4
chmod -R u=r,o=x,g=w oldDir5
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
chown oldUser oldFile
chown oldUser oldDir1
chown -R oldUser oldDir2
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
chgrp oldGroup oldFile
chgrp oldGroup oldDir1
chgrp -R oldGroup oldDir2
#************end**************#

Linux file/directory advanced management II

#!/bin/bash
#在以下部分写出完成任务的命令
#*********begin*********#
du -h oldFile
du -a oldDir
#********* end *********#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
ln oldFile oldFileHardLink
ln -s oldFile oldFileSoftLink
ln -s oldDir oldDirSoftLink
#************end**************#

Linux file/directory advanced management 3

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
chmod u+x,u+s oldFile1
chmod g+s oldDir1
chmod u-s oldFile2
chmod g-s oldDir2
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
chmod o+t oldDir1
chmod o-t oldDir2
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
chattr +i /root/oldFile1
lsattr /root/oldFile2
chattr -i /root/oldFile3
#************end**************#

Chapter 5 Linux Compression and Archives

1
Linux file packaging and decompression

#!/bin/bash
#在以下部分写出完成任务的命令
#*********begin*********#
tar -cvf newFile.tar oldFile1 oldFile2
tar -xvf oldFile.tar
#********* end *********#

#!/bin/bash
#在以下部分写出完成任务的命令
#*********begin*********#
tar -cvf newFile.tar.gz oldFile1 oldFile2
bzip2 oldFile.tar
zip oldDir.zip oldDir
#********* end *********#

#!/bin/bash
#在以下部分写出完成任务的命令
#*********begin*********#
tar -xvf oldFile.tar.gz
bunzip2 oldFile.tar.bz2
unzip oldDir.zip
#********* end *********#

Chapter 6 Linux File Location Commands

1
Linux file/directory search

#!/bin/bash
#在以下部分写出完成任务的命令
#*********begin*********#
locate -c group
touch newFile
updatedb
locate newFile
#********* end *********#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
which useradd
whereis useradd
whereis -m useradd
#************end**************#

#!/bin/bash
#在以下部分写出完成任务的命令
#***********begin*************#
find -name "*.conf"
find -name "my*"
find /root -size +1M
find /root -name "*Link" -type l -exec ls -l {} \;
#************end**************#

Chapter 7 Linux Remote Online Services

2
Linux remote online service (1) - Telnet server
This tutorial has already been provided, I will not answer the Telnet server in detail

Linux remote online service (2) - Rsh server
Rsh server

Chapter 8 Linux Network Combat

4
Linux network combat (1) - DNS configuration

vim /etc/hosts
把下面添加到尾部
127.0.1.1 newLocalhost
127.1.1.1 www.baidu.com

apt-get update
apt-get install bind9

service bind9 start

The DNS configuration file can be copied, remember to delete the line number and keep the format, you can refer to the tutorial in the corresponding head song.

Linux network combat (2) - WWW server construction

apt-get update
apt-get install apache2

service apache2 start

vim /etc/apache2/ports.conf #把80替换为8011
vim /etc/apache2/sites-enabled/000-default.conf @#把80替换为8011
vim /etc/apache2/ports.conf #添加一个端口

insert image description here

vim /etc/apache2/sites-enabled/000-default.conf  #添加一个一模一样的xml文本体,端口叫8082
#并把文档目录修改为/var/www/html/test 如下图所示。

insert image description here

mkdir /var/www/html/test
touch /var/www/html/test/index.html
service apache2 restart

Linux network combat (3) - Samba server construction

apt-get update
apt-get install samba
#建议密码设置为123456
apt-get install smbclient
useradd testUser
smbpasswd -a testUser
touch testFile
vim /etc/samba/smb.conf #在文件尾部添加如下文本 
[ homes]
	comment = smbclient homes
	path = /tmp
	browseable = no
	writable = yes
	create mask = 0664
	directory mask = 0775
service samba start
smbclient //127.0.0.1/testUser -U testUser%123456
smb: \>mkdir Dir
smb: \>put /root/testFile /Dir/upLoadFile
mkdir /testDir
chmod 777 /testDir
useradd testUser
smbpasswd -a testUser(输入新设置的密码123456)
touch testFile
vim /etc/samba/smb.conf #在文件尾部添加如下文本 
"
[TestShare]
	comment = this is my homework
	path = /testDir
	browseable = yes
	writable = yes
	create mask = 0644
	directory mask = 0755
"
service samba restart
service smbd restart
smbclient -L 127.0.0.1 -U testUser%123456 #如果下方有TestShare字样则为成功。
smbclient //127.0.0.1/TestShare -U testUser%123456
(注意:这里的用户是一次性的,每次使用这个连接命令都会使这个用户消失,如果要重新连接,需要新建用户。还要注意文件,也是一次性的,上传之后原文件会消失,若使用过,则需要重新创建)
smb: \>mkdir Dir
smb: \>put /root/testFile /Dir/upLoadFile

Linux network combat (4) - FTP server construction

apt-get update
apt-get install vsftpd
apt-get install ftp
touch testFile
service vsftpd start
vim /etc/vsftpd.conf #在文件尾部添加如下文本 
"
	anon_root=/
	anon_other_write_enable=YES
	anon_umask=022
	anon_upload_enable=YES
	write_enable=YES
	anon_mkdir_write_enable=YES
"
#并将vsftpd.conf文件中 anonymous_enable 设置为 YES  (vim下使用 /anonymous_enable 可以快速找到位置)
service vsftpd restart
ftp localhost
anonymous
回车
cd /tmp
mkdir Dir
send /root/testFile ./Dir/upLoadFile
exit
service vsftpd restart
useradd -m newUser
passwd newUser
密码123456
touch testFile
vim /etc/vsftpd.conf  #将vsftpd.conf文件中pam_service_name对应的值改成 ftp
service vsftpd restart
ftp localhost
newUser
123456
smb: \>put /root/testFile ./upLoadFile
smb: \>exit
service vsftpd restart

Guess you like

Origin blog.csdn.net/weixin_44961083/article/details/128507411