Linux常用命令
2017-08-23 00:00
246 查看
1.查看网络端口占用
2.程序开机自启
3.查找文件
sudo设置
如查找8000端口占用情况 lsof -i:8000 或者 netstat -apn | grep 8000
2.程序开机自启
即在rc.local增加启动代码就可以了。 vi /etc/rc.d/rc.local 增加一行 /usr/local/nginx/sbin/nginx 赋予执行权限,否则不会被执行: chmod u+x rc.local 如果需要以某用户运行,用如下命令 su - username -c “your-cammand” 例如 /bin/su - stingwoh -c "/mnt/mongodb/bin/mongod --config/mnt/mongodb/bin/mongodb.conf"
3.查找文件
find / -name XXX
sudo设置
创建新用户 创建一个用户名为:linuxidc [root@localhost ~]# adduser linuxidc 为这个用户初始化密码,linux会判断密码复杂度,不过可以强行忽略: [root@localhost ~]# passwd linuxidc 更改用户 zhangbiao 的密码 。 新的 密码: 无效的密码: 密码未通过字典检查 - 过于简单化/系统化 重新输入新的 密码: passwd:所有的身份验证令牌已经成功更新。 授权 个人用户的权限只可以在本home下有完整权限,其他目录要看别人授权。而经常需要root用户的权限,这时候sudo可以化身为root来操作。我记得我曾经sudo创建了文件,然后发现自己并没有读写权限,因为查看权限是root创建的。 新创建的用户并不能使用sudo命令,需要给他添加授权。 sudo命令的授权管理是在sudoers文件里的。可以看看sudoers: [root@localhost ~]# sudoers bash: sudoers: 未找到命令... [root@localhost ~]# whereis sudoers sudoers: /etc/sudoers /etc/sudoers.d /usr/libexec/sudoers.so /usr/share/man/man5/sudoers.5.gz 找到这个文件位置之后再查看权限: [root@localhost ~]# ls -l /etc/sudoers -r--r----- 1 root root 4251 9月 25 15:08 /etc/sudoers 是的,只有只读的权限,如果想要修改的话,需要先添加w权限: [root@localhost ~]# chmod -v u+w /etc/sudoers mode of "/etc/sudoers" changed from 0440 (r--r-----) to 0640 (rw-r-----) 然后就可以添加内容了,在下面的一行下追加新增的用户: [root@localhost ~]# vim /etc/sudoers ## Allow root to run any commands anywher root ALL=(ALL) ALL linuxidc ALL=(ALL) ALL #这个是新增的用户 wq保存退出,这时候要记得将写权限收回: [root@localhost ~]# chmod -v u-w /etc/sudoers mode of "/etc/sudoers" changed from 0640 (rw-r-----) to 0440 (r--r-----) 这时候使用新用户登录,使用sudo: [linuxidc@localhost ~]$ sudo cat /etc/passwd [sudo] password for linuxidc: We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. 第一次使用会提示你,你已经化身超人,身负责任。而且需要输入密码才可以下一步。如果不想需要输入密码怎么办,将最后一个ALL修改成NOPASSWD: ALL。
相关文章推荐
- linux常用实战命令
- linux常用命令
- Linux目录结构和常用命令
- Linux 常用命令
- linux 下常用命令记录
- linux 下常用命令
- Linux如何查看进程、杀死进程、启动进程等常用命令
- linux常用的压缩与解压缩命令
- Linux常用命令(二)(课程)
- linux运维必须知道的几个常用命令
- Linux操作常用命令笔记
- linux常用命令
- Linux基本常用命令
- linux常用命令小干货——ps
- Linux(7) 常用命令扩展 改变用户环境变量 (可以实现登陆就执行shell脚本)
- 常用linux命令 centeOS版
- linux常用命令
- Linux常用命令
- linux中的VI常用操作命令
- 第3讲,Linux常用命令(三)