Linux 常用命令
Linux 常用命令
实验题目:
1、启动计算机,利用root用户登录到系统,进入字符提示界面。
sudo passwd
2、查看当前所在的目录。
pwd
3、列出此目录下的文件和目录。
ls
4、列出此目录下包括隐藏文件在内的所有文件和目录。
ls -a
5、用man命令查看ls命令的使用手册。
man ls
6、在当前目录下创建测试目录test。
mkdir test
7、列出当前目录下文件和目录,确认test目录创建成功。
Pwd
8、进入test目录,查看当前工作目录是否是test目录。
cd test
9、利用当前目录创建一个新的空文件newfile。
touch newfile
10、复制系统文件/etc/profile到当前目录下。
cp /etc/profile /root/test
11、复制文件profile 到一个新文件profile.bak作为备份。
cp /etc/profile profile.bak
12、以长格式列出当前目录下的所有文件,注意比较每个文件的长度和创建时间的不同。
ll ls -l
13、分屏查看文件profile 的内容(功能最全的命令),练习其各个子命令,并对then关键字进行查找。
less /etc/profile
14、利用新命令在profile 文件中对关键字then进行查询,并与上面的结果比较。
grep then /etc/profle
15、给文件profile创建一个符号链接lnsprofile和一个硬链接lnhprofile。
ln -s profile lnsprofile(创建软连接)
ln profile lnhprofile(创建硬链接)
16、以长格式显示文件profile 、lnsprofile和Inhprofile 的详细信息
ll 加名字
17、删除文件profile,用长格式显示文件Insprofile 和Inhprofile 的详细信息。
rm -i profile
18、查看文件lnsprofile的内容,看看有什么结果。
19、查看文件Inhprofile 的内容,看看有什么结果。
20、删除文件Insprofile,显示当前目录下的文件列表,回到上层目录。
rm -i lnsprofile cd ..
21、把目录test打包成test. tar。
tar -cvf test.tar test
22、把打好的包进行压缩。
gzip -v test.tar
23、把文件test. tar. gz改名为backup. tar. gz。
mv /root/test.tar.gz backup.tar.gz
24、显示当前目录下的文件和目录列表,确认重命名成功。
ls
25、把文件 backup. tar. gz移动到test 目录下。
mv backup.tar.gz /root/test/
26、显示当前目录下的文件和目录列表,确认移动成功。
ls
27、进入test目录,显示目录中的文件列表。
cd /root/test ls
28、把文件backup. tar. gz解包。
gunzip -v backup.tar.gz
29、显示当前目录下的文件和目录列表(注意观察解包之后的多出来的是什么,并说明理由),复制test 目录为testbak 目录作为备份。
cp -R /root/test/testbak
30、查找root用户自己的主目录下的所有名为newfile的文件。
cd /root find -name newfile
31、删除test子目录下的所有文件。
rm -R test
32、删除空子目录test。
Rmdir test
33、回到上层目录,利用删除目录test和其下所有文件。
34、在/var/lib 目录下查找其所有者是“你新建的用户”的所有文件。
35、在/var目录下查找其所有者是root用户的所有文件。
find /var –user root
36、查找/usr/bin目录下所有大小超过1000000B的文件并用长格式显示。
find /usr/bin -size +1000000c -exec ls -l {} \;
37、查找/tmp目录下属于 root的所有普通文件,这些文件的修改时间为3天以前,查询结果用长格式显示。
find /tmp –user root –and –mtime +3 –and –type f –exec ls {} \;
# find /tmp –user root–and –mtime +3 –and –type f –exec ls {} \\;
38、在/home目录里,用find命令定位文件所有者是root的文件
Find /home -user root
39、在tmp目录下新建test目录,保存/etc目录下的文件到/tmp目录下
Mkdir /tmp/test
Cp -r /etc/* / tmp
Tar cvf /tmp/