linux 基础操作(一)
挂载目录
1、用户密码不对时会提示 Permission denied
[root@localhost /]# mount -t cifs -o username=beijing,password=123456 //192.168.1.102/linux /mnt
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
2、IP 地址不对时会提示 Unable to find suitable address.
[root@localhost /]# mount -t cifs -o username=beijing,password=123456 //192.168.1.100/linux /mnt
Unable to find suitable address.
3、挂载成功
[root@localhost /]# mount -t cifs -o username=beijing,password=123456linux //192.168.1.102/linux /mnt
4、查看挂载目录
[root@localhost /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/rhel-root 32G 4.5G 27G 15% /
devtmpfs 2.2G 0 2.2G 0% /dev
tmpfs 2.2G 84K 2.2G 1% /dev/shm
tmpfs 2.2G 8.7M 2.2G 1% /run
tmpfs 2.2G 0 2.2G 0% /sys/fs/cgroup
/dev/sda1 497M 159M 339M 32% /boot
/dev/mapper/rhel-home 16G 38M 16G 1% /home
tmpfs 438M 16K 438M 1% /run/user/42
tmpfs 438M 0 438M 0% /run/user/0
//192.168.1.102/linux 301G 296G 5.8G 99% /mnt
5、取消挂载
[root@localhost /]# umount -t cifs /mnt
6、查看挂载目录
[root@localhost /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/rhel-root 32G 4.5G 27G 15% /
devtmpfs 2.2G 0 2.2G 0% /dev
tmpfs 2.2G 84K 2.2G 1% /dev/shm
tmpfs 2.2G 8.7M 2.2G 1% /run
tmpfs 2.2G 0 2.2G 0% /sys/fs/cgroup
/dev/sda1 497M 159M 339M 32% /boot
/dev/mapper/rhel-home 16G 38M 16G 1% /home
tmpfs 438M 16K 438M 1% /run/user/42
tmpfs 438M 0 438M 0% /run/user/0
切换目录
[root@localhost /]# cd /mnt
打印当前目录
[root@localhost mnt]# pwd
/mnt
查看使用过的命令
[root@localhost mnt]# history
1 mount --types
2 mount -t cifs -o username=beijing.password=123456 //192.168.1.102/LENOVO-PC/linux /mnt
查看端口被占用情况
[root@localhost mnt]# lsof -i:8088
杀死占用端口的程序
[root@localhost mnt]# kill -9 80
创建目录
[root@localhost mnt]# mkdir zhzkTest
[root@localhost mnt]# ls
zhzkTest
删除目录
[root@localhost mnt]# rmdir zhzkTest
[root@localhost mnt]# ls
linux 系统下登录其它 linux 系统
[root@localhost /]# ssh 192.168.1.110
The authenticity of host '192.168.1.110 (192.168.1.110)' can't be established.
ECDSA key fingerprint is 53:e5:5b:9b:b7:f7:e2:b8:35:6c:0b:73:97:60:a6:3d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.110' (ECDSA) to the list of known hosts.
root@192.168.1.110's password:
Last login: Sat May 7 10:38:01 2016 from 192.168.1.110
[root@localhost ~]
复制文件(从本地 /tmp/test/yum.log(192.168.1.110)linux 系统复制到远程的 192.168.1.103linux 系统 tmp 目录下)
[root@localhost /]# scp /tmp/test/yum.log root@192.168.1.103:/tmp/
root@192.168.1.103's password:
yum.log 100% 0 0.0KB/s 00:00
[root@localhost /]# exit
logout
Connection to 192.168.1.110 closed.
[root@localhost /]# cd /tmp
[root@localhost tmp]# ls
hsperfdata_root ks-script-_reXYv yum.log
复制文件文件夹(从本地 /tmp/test/(192.168.1.110)linux 系统复制到远程的 192.168.1.103linux 系统 tmp 目录下)
[root@localhost tmp]# ssh 192.168.1.110
root@192.168.1.110's password:
Last login: Sat May 7 12:53:48 2016 from 192.168.1.103
[root@localhost ~]# scp -r /tmp/test root@192.168.1.103:/tmp/
root@192.168.1.103's password:
yum.log 100% 0 0.0KB/s 00:00
[root@localhost ~]# exit
logout
Connection to 192.168.1.110 closed.
[root@localhost tmp]# ls
hsperfdata_root ks-script-_reXYv test yum.log
[root@localhost tmp]# cd ./test
[root@localhost test]# ls
yum.log
[root@localhost test]#
删除文件
[root@localhost test]# ls
yum.log
[root@localhost test]# rm yum.log
rm: remove regular empty file ‘yum.log’? yes
[root@localhost test]# ls
[root@localhost test]#
删除文件夹
[root@localhost tmp]# ls
hsperfdata_root ks-script-_reXYv test yum.log
[root@localhost tmp]# rm -rf test
[root@localhost tmp]# ls
hsperfdata_root ks-script-_reXYv yum.log
[root@localhost tmp]#
查看文件属性
[root@localhost tmp]# ls -l
total 4
drwxr-xr-x. 2 root root 17 May 7 11:37 hsperfdata_root
-rwx------. 1 root root 827 May 7 12:05 ks-script-_reXYv
-rw-------. 1 root root 0 May 7 13:01 yum.log
[root@localhost tmp]# ls -a
. .font-unix .ICE-unix .rnd .X11-unix yum.log
.. hsperfdata_root ks-script-_reXYv .Test-unix .XIM-unix
[root@localhost tmp]# lsattr
---------------- ./yum.log
---------------- ./hsperfdata_root
---------------- ./ks-script-_reXYv
[root@localhost tmp]#
[root@localhost tmp]# file yum.log
yum.log: empty
[root@localhost tmp]# stat yum.log
File: ‘yum.log’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 201326722 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:initrc_tmp_t:s0
Access: 2016-05-07 11:10:13.643997365 +0800
Modify: 2016-05-07 13:01:32.506524469 +0800
Change: 2016-05-07 13:01:32.506524469 +0800
Birth: -
[root@localhost tmp]#
移动文件
[root@localhost tmp]# ls
hsperfdata_root ks-script-_reXYv yum.log
[root@localhost tmp]# mkdir test
[root@localhost tmp]# ls
hsperfdata_root ks-script-_reXYv test yum.log
[root@localhost tmp]# mv yum.log ./test
[root@localhost tmp]# ls
hsperfdata_root ks-script-_reXYv test
[root@localhost tmp]# cd ./test
[root@localhost test]# ls
yum.log
[root@localhost test]#
[root@localhost test]# stat yum.log
File: ‘yum.log’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 201326722 Links: 1
Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:initrc_tmp_t:s0
Access: 2016-05-07 11:10:13.643997365 +0800
Modify: 2016-05-07 13:01:32.506524469 +0800
Change: 2016-05-07 13:31:42.481572039 +0800
Birth: -
[root@localhost test]#
查找命令所在位置
[root@localhost /]# which java
/usr/bin/java
[root@localhost /]# which ip
/usr/sbin/ip
[root@localhost /]# which rm
alias rm='rm -i'
/usr/bin/rm
[root@localhost /]#
[root@localhost /]# which ifconfig
/usr/sbin/ifconfig
广范围根据文件名查找
[root@localhost /]# whereis ifconfig
ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
注意:如果 which 没有找到要找的命令,可以试试 whereis, 该命令搜索更大的范围的系统目录。有些系统上的 which 命令不显示用户没有执行权限的文件
例如:
[root@localhost /]# which ipppd
/usr/bin/which: no ipppd in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/beijing/.local/bin:/home/beijing/bin)
[root@localhost /]# whereis ipppd
ipppd:[root@localhost /]#