Linux使用中的一些基础命令的使用
压缩、解压
tar
#压缩etc目录打包成一个tar包tar -cvf etc.tar etc/#解压tar包tar -xvf xxx.tar#压缩etc目录打包成一个tar.gz包tar -cvzf etc.tar.gz etc/#解压tar.gztar -zxvf xxx.tar.gz
unzip
#查看zip压缩包内的文件unzip -l xxx.zip#解压xxx.zip解压当前文件夹下unzip xxx.zip#解压xxx.zip到tmp文件夹下,并且不要覆盖已有文件unzip -n xxx.zip -d /tmp#将xxx.zip解压到/tmp目录下,并且覆盖已有文件unzip -o xxx.zip -d tmp/
防火墙的关闭和开启
CentOS6
#查看防火墙的状态service iptables status#临时关闭防火墙service iptables stop#永久关闭防火墙chkconfig iptables off
CentOS7
#查看默认防火墙状态firewall -cmd --state#检查防火墙的状态systemctl status firewalld.service#停止firewallsystemctl stop firewalld.service#禁止firewall开机启动systemctl disable firewalld.service
后台运行
nohup
#不挂断的允许命令,无论是否将 nohup 命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中,如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中,如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用nohup COMMAND "startxxxx.sh"#&指后台运行,当command和&一起使用时,能使命令永久的在后台执行,日志会存在nohup.out文件中nohup COMMAND "startxxxx.sh" &
进程查看
ps -aux
#查找到运行脚本的 PIDps -aux | grep "startxxxx.sh"
ps -ef
#查找到 运行脚本到的PIDps -ef | grep "startxxxx.sh"
netstat -ap
#查看使用某端口的进程netstat -ap|grep 端口号
netstat -nap
#根据进程id查看其占用的端口netstat -nap|grep 进程id
进程终止
kill
#根据pid杀死进程kill 进程号#强制杀死进程kill -9 进程号
无权限执行
chmod
#在Linux中启动tomcat时,没有执行权限运行该程序,在tomcat 的bin目录下 执行这条命令chmod +x *.sh
查看最近输入语句
history
history
