Linux基础学习笔记以及常用命令
[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]# id test
id: test: no such user
[root@VM_64_7_centos tmp]# id root
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]# useradd test
[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test)
[root@VM_64_7_centos tmp]# gpasswd -a test root
Adding user test to group root
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test),0(root)
[root@VM_64_7_centos tmp]# gpasswd -d test root
Removing user test from group root
[root@VM_64_7_centos tmp]# id test
uid=1000(test) gid=1000(test) groups=1000(test)
[root@VM_64_7_centos ~]# passwd test
Changing password for user test.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[test@VM_64_7_centos tmp]$ id
uid=1000(test) gid=1000(test) groups=1000(test)
[test@VM_64_7_centos tmp]$ su - root
Password:
[root@VM_64_7_centos tmp]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_64_7_centos tmp]#
[root@VM_64_7_centos tmp]# userdel -r test
[root@VM_64_7_centos tmp]# id test
id: test: no such user
[root@VM_64_7_centos tmp]# ls -l
total 8
-r--r--r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod g+w o+x ./test.sh
chmod: cannot access 'o+x': No such file or directory
[root@VM_64_7_centos tmp]# chmod g+w ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-r--rw-r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+wx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxrw-r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod o+x ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxrw-r-x 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod a-rwx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+rwx ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 000 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod u+001 ./test.sh
chmod: invalid mode: 'u+001'
Try 'chmod --help' for more information.
[root@VM_64_7_centos tmp]# chmod 001 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
---------x 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 020 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-----w---- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 400 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-r-------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 600 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rw------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 700 ./test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwx------ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# chmod 744 test.sh
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxr--r-- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]#
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
[root@VM_64_7_centos tmp]# setfacl -m u:test:rwx test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
user:test:rwx
group::r-x
mask::rwx
other::r-x
[root@VM_64_7_centos tmp]# setfacl -x user:test test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
mask::r-x
other::r-x
[root@VM_64_7_centos tmp]# ls -l
total 8
-rwxr-xr-x+ 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# setfacl -b test.sh
[root@VM_64_7_centos tmp]# getfacl test.sh
# file: test.sh
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
[root@VM_64_7_centos tmp]#
运行结果:
[root@VM_64_7_centos tmp]# ls -l
total 8
---------- 1 root root 616 Dec 18 13:48 test.sh
[root@VM_64_7_centos tmp]# bash test.sh
current sh file name ./test.sh ./test.sh ./test.sh_file
10470
total value is:4
10 * 20 = 200
a==b or a>0
9
file enable write
file is not empty
0
1
2
a
b
c
array length is 3; array contain element is: a b c
5
6
call count function 10+20=30
[root@VM_64_7_centos tmp]# ./test.sh
-bash: ./test.sh: Permission denied
sheel脚本内容:
#! /bin/bash
echo "current sh file name $0 ${0} $0_file"
echo $$
value=`expr 2 + 2`
echo "total value is:${value}"
a=10
b=20
ab=`expr $a \* $b`
echo "$a * $b = $ab"
#echo "please inputi c:"
#read c
#ab=`expr $a / $c`
#echo "$a/$c=${ab}"
if [ $a == $b -o $a -gt 0 ];
then
echo "a==b or a>0"
else
echo "a!=b"
fi
str="dog,cat,fish,cattle,pig,rabbit"
echo `expr index $str fish`
file="/usr/tmp/file.test"
if [ -e ${file} ]
then
if [ -w $file ]
then
echo "file enable write"
fi
if [ -s $file ]
then
echo "file is not empty"
else
echo "file is empty"
fi
fi
#loop
for ((i=0;i<3;i++))
do echo $i
done
#array=(a b c)
array[0]=a
array[1]=b
array[2]=c
for i in ${array[@]}
do echo $i
done
echo "array length is" ${#array[@]}"; array contain element is:" ${array[@]}
j=5
while [ $j -lt 7 ]
do
echo $j
j=$(($j+1))
done
name=bird
case $name in
dog)
echo $name;;
cat)
echo $name;;
fish)
echo $name;;
rabbit)
echo $name;;
esac
total=0
count(){
total=$(($1+$2))
}
count 10 20
echo "call count function 10+20=$total"
echo ${array[@]} >> /usr/tmp/file.test
<<EOF
read var
echo "You input is $var"
EOF
最新文章
- EC笔记:第三部分:16成对使用new和delete
- .NET LINQ查询语法与方法语法
- *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext iOS9.1闪退问题解决
- Performance Analysis Methodology
- ViewPager的监听事件失效
- [Everyday Mathematics]20150303
- U3D 收藏一个飞机随机运动的方法
- Java ---自定义标签
- JavaScript中apply与call方法
- dbda数据库类
- [Machine Learning]学习笔记-线性回归
- 【编程技巧】EXTJS中Ext.grid.GridPanel配置项autoExpandColumn的使用方法
- 特殊权限SUIG、SGID、SBIT
- CRM客户关系管理系统(八)
- sqlserver笔记----创建用户赋予权限
- 叮咚,你的Lauce上线了!
- 单元测试系列之五:Mock工具之Mockito实战
- mac node版本管理
- oauth2 java 代码示例
- 有趣的HTML5 CSS3效果
热门文章
- HDU 5791 Two(训练题002 F)
- asp.net应用发布到IIS无法链接到oracle数据库
- 解决ajax的parsererror错误的终极办法(后台传给前台的数据json问题)
- 项目实战2.2—nginx 反向代理负载均衡、动静分离和缓存的实现
- JS--我发现,原来你是这样的JS:面向对象编程OOP[3]--(JS继承)
- 获取所有栈的信息,只有最上面的和最下面的,但是不能获取栈中间的activity信息
- [转载] Hadoop MapReduce
- 使用flex
- Facebook-Haystack合并小文件
- python操作Mysql基础