`

Linux常用命令

阅读更多
1、free

该命令用于查看当前系统内存的使用情况,它可以显示系统中剩余及已用的物理内存、交换内存、共享内存和内核缓冲区。


2、top

使用方式:top [-] [d delay] [q] [c] [S] [s] [n]

说明:即时显示 process 的动态
d : 改变显示的更新速度,或是在交谈式指令列( interactive command)按 s
q : 没有任何延迟的显示速度,如果使用者是有 superuser 的权限,则 top 将会以最高的优先序执行
c : 切换显示模式,共有两种模式,一是只显示执行档的名称,另一种是显示完整的路径与名称S : 累积模式,会将己完成或消失的子行程 ( dead child process ) 的 CPU time 累积起来
s : 安全模式,将交谈式指令取消, 避免潜在的危机
i : 不显示任何闲置 (idle) 或无用 (zombie) 的行程
n : 更新的次数,完成后将会退出 top
b : 批次档模式,搭配 "n" 参数一起使用,可以用来将 top 的结果输出到档案内

范例:
显示更新十次后退出 ;
top -n 10


3、ps

使用方式:ps [options] [--help]
说明:显示瞬间行程 (process) 的动态
参数:
ps 的参数非常多, 在此仅列出几个常用的参数并大略介绍含义
-A 列出所有的行程
-w 显示加宽可以显示较多的资讯
-au 显示较详细的资讯
-aux 显示所有包含其他使用者的行程
==============================================================

netstat -na --ip  检查端口使用
pgrep xinet       查看xinet 的pid
service vsftpd start  启动vsftpd服务
which vsftpd 查看vsftpd的目录
chmod u+x jdk...bin 授予jdk..bin的执行权限
(jdk安装后在:/usr/java/jdk.../bin中)
source /etc/profile 将profile导入的变量立即生效

即可把a.txt拷贝到当前目录
cp /home/xp/a.txt ./

查看liunx的版本
cat /proc/version

修改指定用户密码:
[root@localhost ~]# passwd single
查看用户:
1.cat /etc/passwd

2.As we all know that by default all the users created will have their home directories in /home share
so we'll modify our command a bit by using grep.
Now it'll be
cat /etc/passwd | grep "/home"

3. Now we'll get all the user accounts which have their home share in /home.
But the only output we need is the list of users & nothing else.

4. So we'll modify our command again
cat /etc/passwd | grep "/home" |cut -d: -f1
Now what we have done is that we have piped the output of previous command to another variable "cut"
What we have done here is we have added
cut -d: -f1
-d: means delimiter :
-f1 means display first field of line i.e. username.

So final command is
Cat /etc/passwd |grep "/home" |cut -d: -f1

This works until all your users have their home share in /home. If you have defined their home share to some other destination. Modify the above command.


(Hint : In previous case we started grep "/home" , this time we'll use grep "/bin/bash" or whatever valid shell you are using)

Now command will be like..
Cat /etc/passwd |grep "/bin/bash" |cut -d: f1
可以看出grep 命令和 cut命令的 以及管道的作用


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics