加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux常用命令

发布时间:2020-12-13 14:03:14 所属栏目:Linux 来源:网络整理
导读:pre class="recommend-text mb-10"span style="color: #ff0000;"1.tar 建立压缩的tar包:tar zcvf 压缩的包名字 所备份的文件或者目录(z代表使用gzip程序进行压缩)释放tar 包:tar xvf 包的名字(x代表释放文件)释放压缩的tar包:tar zxvf 压缩的tar包的名

<pre class="recommend-text mb-10"><span style="color: #ff0000;">1.tar建立压缩的tar包:tar zcvf 压缩的包名字 所备份的文件或者目录(z代表使用gzip程序进行压缩)释放tar 包:tar xvf 包的名字(x代表释放文件)释放压缩的tar包:tar zxvf 压缩的tar包的名字(z代表解压文件)<span style="color: #ff0000;">1.1 unzip 解压war包unzip -oq common.war -d common<span style="color: #ff0000;">2.<span class="ask-title">linux下如何验证weblogic已经启动命令
<pre class="best-text mb-10">直接使用 netstat ? -anp ? | ? grep??portno使用<span style="font-size: medium;"><span style="color: #009900;">绝杀 kill -9 PID<span style="color: #ff0000;">3.<span style="color: #ff0000;">shell判断文件,目录是否存在或者具有权限 ?
<pre class="best-text mb-10">

? #!/bin/sh ?
??
myPath="/var/log/httpd/" ?
myFile="/var /log/httpd/access.log" ?
??
#这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 ?
if [ ! -x "$myPath"]; then ?
mkdir "$myPath" ?
fi ?
?www.2cto.com ?
#这里的-d 参数判断$myPath是否存在 ?
if [ ! -d "$myPath"]; then ?
mkdir "$myPath" ?
fi ?
??
#这里的-f参数判断$myFile是否存在 ?
if [ ! -f "$myFile" ]; then ?
touch "$myFile" ?
fi ?
??
#其他参数还有-n,-n是判断一个变量是否是否有值 ?
if [ ! -n "$myVar" ]; then ?
echo "$myVar is empty" ?
exit 0 ?
fi ?
??
#两个变量判断是否相等 ?
if [ "$var1" = "$var2" ]; then ?
echo '$var1 eq $var2' ?
else ?
echo '$var1 not eq $var2' ?
fi ?
$n????????$1?the?first?parameter,$2?the?second... $#????????The?number?of?command-line?parameters. $0????????The?name?of?current?program. $?????????Last?command?or?function's?return?value. $$????????The?program's?PID. $!????????Last?program's?PID. $@????????Save?all?the?parameters.
?
[ -f $file_var ]: Returns true if the given variable holds a regular filepath orfilename.[ -x $var ]: Returns true if the given variable holds a file path or filename which is executable.[ -d $var ]: Returns true if the given variable holds a directory path or directory name.[ -e $var ]: Returns true if the given variable holds an existing file.[ -c $var ]: Returns true if the given variable holds path of a character device file.[ -b $var ]: Returns true if the given variable holds path of a block device file.[ -w $var ]: Returns true if the given variable holds path of a file which is writable.[ -r $var ]: Returns true if the given variable holds path of a file which is readable.[ -L $var ]: Returns true if the given variable holds path of a symlink.
?
6. 文件修改用户组权限
chown -hR usergroup:user filename
需要root权限
chown sudo usergroup:user filename
?
7. vi文件中的替换
:%s/source/replace /g
?
8. 文件替换
? sed -i "s/oldString/newString/g" `grep oldString -rl /path`
注意,后面的标点符号为esc下面的`键,而非单引号‘
?
9. 查看文件的其中几行
?sed -n '5,10p' filename 这样你就可以只查看文件的第5行到第10行。

系统

# uname -a               # 查看内核/操作系统/CPU信息
# head -n 1 /etc/issue   # 查看操作系统版本
# cat /proc/cpuinfo      # 查看CPU信息
# hostname               # 查看计算机名
# lspci -tv              # 列出所有PCI设备
# lsusb -tv              # 列出所有USB设备
# lsmod                  # 列出加载的内核模块
# env                    # 查看环境变量

资源

# free -m                # 查看内存使用量和交换区使用量
# df -h                  # 查看各分区使用情况
# du -sh <目录名>        # 查看指定目录的大小
# grep MemTotal /proc/meminfo   # 查看内存总量
# grep MemFree /proc/meminfo    # 查看空闲内存量
# uptime                 # 查看系统运行时间、用户数、负载
# cat /proc/loadavg      # 查看系统负载

磁盘和分区

# mount | column -t      # 查看挂接的分区状态
# fdisk -l               # 查看所有分区
# swapon -s              # 查看所有交换分区
# hdparm -i /dev/hda     # 查看磁盘参数(仅适用于IDE设备)
# dmesg | grep IDE       # 查看启动时IDE设备检测状况

网络

# ifconfig               # 查看所有网络接口的属性
# iptables -L            # 查看防火墙设置
# route -n               # 查看路由表
# netstat -lntp          # 查看所有监听端口
# netstat -antp          # 查看所有已经建立的连接
# netstat -s             # 查看网络统计信息

进程

# ps -ef                 # 查看所有进程
# top                    # 实时显示进程状态

用户

# w                      # 查看活动用户
# id <用户名>            # 查看指定用户信息
# last                   # 查看用户登录日志
# cut -d: -f1 /etc/passwd   # 查看系统所有用户
# cut -d: -f1 /etc/group    # 查看系统所有组
# crontab -l             # 查看当前用户的计划任务

服务

# chkconfig --list       # 列出所有系统服务
# chkconfig --list | grep on    # 列出所有启动的系统服务

程序

# rpm -qa                # 查看所有安装的软件包连接ln -s source dist????????# 建立软连接??1. ln source dist????????????# 建立硬连接? 

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读