位数
getconf LONG_BIT
网关
cat /etc/sysconfig/network
DNS
cat /etc/resolv.conf
CPU
more /proc/cpuinfo | grep "model name"
内存
free -h
cat /proc/meminfo
硬盘
df -h
查看Linux所有版本信息
cat /proc/version
lsb_release -a
#查看内核
uname -r
修改分组所有者和文件目录权限
chown -R www:www filedir
chmod -R 777 filedir
查看主机名
hostname
修改临时主机名字
hostname hsxiang.com
永久修改
/etc/hosts
/etc/sysconfig/network
查看端口
netstat -lnp|grep 80
#需要安装lsof
lsof -i:(port)
查看apache进程
ps -aux | grep apache
查看系统所有用户
cat /etc/passwd |cut -f 1 -d :
用户相关操作
将一个用户添加到用户组中,千万不能直接用:
usermod -G groupA
应该用 加上 -a 选项:
usermod -a -G groupA user
usermod -a -G nginx svn
usermod -a -G root svn
从组中删除用户
gpasswd -d user GROUP
gpasswd -d svn nginx
查看所有用户组
cat /etc/group
移动文件或目录
移动当前文件夹下的所有文件到上一级目录
mv * ../
把当前目录的一个子目录里的文件移动到另一个子目录里
mv test3/*.txt test5
文件被覆盖前做简单备份,前面加参数-b
mv log1.txt -b log2.txt
文件改名
mv test.log test1.txt
移动文件
mv test1.txt test3
压缩zip
Linux下的压缩解压缩命令详解及实例
实例:压缩服务器上当前目录的内容为xxx.zip文件
zip -r xxx.zip ./*
解压zip文件到当前目录
unzip filename.zip
unzip -o -d /home myfile.zip
把myfile.zip文件解压到 /home
-o:不提示的情况下覆盖文件;
-d:-d /home 指明将文件解压缩到/home目录下;
压缩tar
#解压缩文件
tar -zxvf filename.tar.gz
#压缩
压缩:tar zcvf FileName.tar.gz DirName
建立软连接,类似Windows下的快捷方式
ln -s apache-maven-3.5.4 maven
远程文件复制
一、将本机文件复制到远程服务器上
scp /usr/local/hello.txt root@192.168.1.30:/绝对路径
二、将远程服务器上的文件复制到本机
scp root@192.168.1.20:/usr/local/hello.txt /绝对路径