码迷,mamicode.com
首页 > 系统相关 > 详细

linux学习总结

时间:2016-09-15 16:29:29      阅读:316      评论:0      收藏:0      [点我收藏+]

标签:

提示符:

【root@localhost home】#/$:root 当前用户名;localhost 主机名;home 当前目录;# root用户的提示符;$ 普通用户的提示符

图像界面和命令界面的切换:

vi /etc/inittab

id:3 命令模式,id:5图像界面

系统修改环境变量:

vi /etc/profile     开机加载

 

JAVA_HOME:普通变量

PATH:程序运行时会从变量的指定目录中查找所需

/home/.bash_profile   用户环境变量,用户登录时加载

 

resoure  /etc/profile     立即生效环境变量

关机:

shutdown -h  now/5      在指定时间关机,now当前,5 5分钟后

init 0       

halt

logout

exit

重启:

reboot

shutdown -r now/5        在指定时间重启,now当前重启,5 5分钟后重启

命令帮助:

man  commond

info  commond

commongd   -help

whatis

修改系统日期:

date                   显示当前日期

date +‘%Y%m%d-%H%M%S’格式化输出

date  -s "20160910 22:58:00" 修改时间

cal  [月][年]                   显示日历

文件和目录操作:

cd  /usr/local               跳转到指定目录

cd  ..                        回到上层目录

cd  ../..                       回到上两层目录

cd -                           回到上次操作目录

cd  ~user                      回到用户user的家目录

ls                         显示当前目录内容

ls -al                       a 显示隐藏默认,l显示文件详细信息

ls  *.txt                   显示所有 txt文件

ls  /usr/local               显示指定目录下的内容

ls -F                      查看目录中的文件

touch  1.txt 2.txt                  新建文件

mkdir  /usr/local/aa              新建目录

mkdir  -p  /usr/local/bb/cc        新建目录,且无父目录时创建父目录

rmdir   /usr/local/bb/cc           删除空目录

mv   old_name.txt  new_name.txt  重命名

cp  目录/文件  /目录/文件        copy一个文件

cp  file/*  .                        copy 目录下的全部文件到当前目录

cp -a file    .                     copy 目录文件到当前目录

rm -rf file                        r强制删除文件,f删除文件夹和内容

pwd                            显示当前目录

who                          查看当前登录用户

whoami                      当前操作用户是谁

su root                       切换用户

sudo  root                      以root用户运行

ssh  

cat  -n  file                 -n 显示行号,查看文件内容

cat file1 file2 > file3              file1和file2的查询输出到file3

tac  file                       从尾部显示文件内容

less   file                分页显示文件,enter换行,“ ”空格换页

more file              分页显示文件,     

tail -f file                  从尾部动态显示文件内容

tail -500 file               显示最后500行

tail +500                 从500行开始显示

head -500 file               从头显示500行

ps -ef|grep mysql |grep -v gerp    查询mysql是否启动,查询进程结果去除grep查询进程

df -h                        查看磁盘空间

du -h                        查看文件大小

useradd username            新建用户

userdel  username         删除用户

usermod                  修改用户信息

passwd  username         修改用户密码

groupadd  groupname          新建组

groupdel   groupnaem        删除组

chmod   ugo+rwx   file      给用户指定权限

chmod ugo+777   file

chmod  ugo-r            

chmod   777  file

chmod -R 777 file         修改文件和文件目录下的全部文件的权限

chown -R user:group file  修改文件和文件下的全部内容所属用户和组

chgrp  -R group file     递归修改文件的所属组

clear   清屏

history   显示历史命令,默认显示1000个,显示个数可以配置

uniq  file    删除文件的重复行

diff  file file2    逐行对比文件内容,列出不同

comm file file1   比较两个排序过的文件

sort  file       对文件进行排序后输出

grep  ‘aa‘  file   查询包含aa的所以行

grep   ‘^a‘  file  查询首字母是a的所有行

find /  -name 1.txt  在根目录查找名称是1.txt的文件

find  /usr/local -name "[1-3]*.txt"

gzip -1 trv 1.txt    压缩结果为 1.txt.gz

gunzip 1.txt.gz    解压gz文件

zip -r /usr/local/1.zip  /etc   把etc下的文件和文件夹压缩成1.zip

unzip -o  1.zip   -d /etc  -o 解压时覆盖已经存在的文件,并且不要求用户确认

-d 目录名  吧压缩文件解压到指定目录下

tar -zxvf  1.tar  解压文件

tar -zcvf  1.tar  test   压缩test 为1.tar

scp 192.168.0.107:/usr/local/1.txt 192.168.0.112:/usr/local    copy 一个系统的文件到另外一个系统

watch -n 3 mkdir 1 2 3   每隔3秒,创建目录 1 2 3

ps -ef      查看当前运行的进程

top

kill  -9 1111    -9 强制删除,1111进程号

commond  &   后台运行

 

系统服务:

 

chkconfig  更新、启动,停止服务

常见服务:iptables  防火墙  network 网络 httpd apache  nginx nginx

chkconfig  iptables on  开启防火墙,永久生效

chkconfig iptables off   关闭防火墙,永久生效

service iptables start  即时开启防火墙,重启失效

service iptables stop  即时关闭防火墙,重启失效

chkconfig iptables --list  查看防火墙

 

系统服务-sercice方式启动脚本:

Chkconfig命令主要是用户启动,停止,查询服务的

Chkconfig–add 1.sh 添加1.sh 为系统服务,1.sh必须放到/etc/rc.d/init.d目录下

Chkconfig–del 1.sh  删除1.sh服务

Chkconfig 1.sh on   开机启动

Chkconfig 1.sh off    关闭开机启动

service 1.sh start    运行1.sh服务

service 1.sh stop     停止服务

 

 

开机启动脚本:

把需要开机执行的脚本加到开机启动配置文件/etc/rc.d/rc.local中

例如:在rc.local中加入/opt/lampp/lampp  start  ,开机时执行rc.local中的lampp启动脚本

 

linux学习总结

标签:

原文地址:http://www.cnblogs.com/lingdangyameng/p/5874828.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!