您的位置:首页 > 运维架构 > Linux

linux基础操作

2016-05-06 20:18 627 查看
1.

# cd /home

# mkdir tmp
# chmod 644 tmp/

2.

# touch test.txt

# vi test.txt

点i开始插入内容
点击Esc推出插入模式,输入:wq!保存并退出

3.
# sed -n "5,10p" test.txt

4.

ctime Create time是在写入文件、更改所有者、权限或链接设置时随 Inode 的内容更改而更改的。

# ls -lc test.txt

atime Access time是在读取文件或者执行文件时更改的。

# ls -lu test.txt

mtime Modified time是在写入文件时随文件内容的更改而更改的。
# ls -l test.txt

5

# find /home/ -ctime -1

# find /home/ -mtime -1

# find /home/ -size +2M

6

查看/home/tmp目录的使用情况

# cd /home/tmp/

# du -h

查看系统的资源使用情况

# df -h

7.

# cd /home/tmp/

# mkdir worker

8

# cd /home/tmp/

# cp test.txt worker/test01.txt

9.

# ln test01.txt hard

# ln -s test01.txt  soft

# ll

总用量 16

drwxr-xr-x 2 root root 4096  5月  6 19:20 ./

drw-r--r-- 3 root root 4096  5月  6 19:19 ../

-rw-r--r-- 2 root root  634  5月  6 19:19 hard

lrwxrwxrwx 1 root root   10  5月  6 19:20 soft -> test01.txt

-rw-r--r-- 2 root root  634  5月  6 19:19 test01.txt

inode(index node)文件索引节点。

硬链接与原文件拥有同样的inode,是同一个文件使用了多个别名

软链接有着自己的 inode 号以及用户数据块,用户数据块中存放的是源文件的路径名

删除原文件对硬链接文件没影响,但是软链接失效。

10.

# touch 1.txt

# echo "I'm chinese" > 1.txt

# touch 2.txt

# echo "Are you OK?" > 2.txt

# cat 1.txt

I'm chinese

# cat 2.txt

Are you OK?

# cat 1.txt 2.txt -n

     1    I'm chinese

     2    Are you OK?

# cat -n 1.txt 2.txt > 3.txt

11.

# find /home/ -name *cu*

# find /home/tmp/ -type f | xargs grep "cu"

12.

# tree /usr/

13.

# chmod u+w test.txt

# chmod ug+r test.txt

# chmod u+x test.txt

14.

# ps -ef | grep sql > sql.log

15.

# tar -zcPvf /home/myfile.tar.gz /home/tmp

16.

# echo $PATH

# export PATH=/mypath/to/dir/:$PATH

# unset PATH

17.

# ping 127.0.0.1

# telnet 127.0.0.1 22

18.

# scp test.txt root@127.0.0.1:/home/

# ssh 127.0.0.1

password:

# ls /home/test.txt

19.

# ftp 127.0.0.1

username:

password:

ftp> put test.txt

ftp> get test.txt
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux