linux命令简谈

1.光标移动命令

按键行动
Ctrl-a移动光标到行首。
Ctrl-e移动光标到行尾。
Ctrl-f光标前移一个字符;和右箭头作用一样。
Ctrl-b光标后移一个字符;和左箭头作用一样。
Alt-f光标前移一个字。
Alt-b光标后移一个字。
Ctrl-l清空屏幕,移动光标到左上角。clear 命令完成同样的工作。

2.进程

ps– Report a snapshot of current processes

top – Display tasks

jobs – List active jobs

bg – Place a job in the background

fg – Place a job in the foreground

kill – Send a signal to a process

killall – Kill processes by name

shutdown – Shutdown or reboot the system

ps – 报告当前进程快照

top – 显示任务

jobs – 列出活跃的任务

bg – 把一个任务放到后台执行

fg – 把一个任务放到前台执行

kill – 给一个进程发送信号

killall – 杀死指定名字的进程

shutdown – 关机或重启系统

进程是怎样工作的
When a system starts up, the kernel initiates a few of its own activities as processes and launches a program called init. init, in turn, runs a series of shell scripts (located in /etc) called init scripts, which start all the system services. Many of these services are implemented as daemon programs, programs that just sit in the background and do their thing without having any user interface. So even if we are not logged in, the system is at least a little busy performing routine stuff.

当系统启动的时候,内核先把一些它自己的活动初始化为进程,然后运行一个叫做 init 的程序。init, 依次地,再运行一系列的称为 init 脚本的 shell 脚本(位于/etc),它们可以启动所有的系统服务。 其中许多系统服务以守护(daemon)程序的形式实现,守护程序仅在后台运行,没有任何用户接口(User Interface)。 这样,即使我们没有登录系统,至少系统也在忙于执行一些例行事务。
The fact that a program can launch other programs is expressed in the process scheme as a parent process producing a child process.

在进程方案中,一个程序可以发动另一个程序被表述为一个父进程可以产生一个子进程。

The kernel maintains information about each process to help keep things organized. For example, each process is assigned a number called a process ID or PID. PIDs are assigned in ascending order, with init always getting PID 1. The kernel also keeps track of the memory assigned to each process, as well as the processes’ readiness to resume execution. Like files, processes also have owners and user IDs, effective user IDs, etc.

内核维护每个进程的信息,以此来保持事情有序。例如,系统分配给每个进程一个数字,这个数字叫做 进程(process) ID 或 PID。PID 号按升序分配,init 进程的 PID 总是1。内核也对分配给每个进程的内存和就绪状态进行跟踪以便继续执行这个进程。 像文件一样,进程也有所有者和用户 ID,有效用户 ID,等等。

3.权限

确定了一个文件的访问权限后,用户可以利用Linux系统提供的chmod命令来重新设定不同的访问权限。也可以利用chown命令来更改某个文件或目录的所有者。利用chgrp命令来更改某个文件或目录的用户组。

选项说明
身份
u所有者(user)
g所属组(group)
o其他(other)
a所有(all)
操作
+添加
-去掉
=设置
权限
r可读
w可写
x可执行
-没有权限

4. 查找命令

find 用于在系统内搜索指定文件

方法:说明
find[路径] [参数] [文件名]
-name按文件名查找
-iname按文件名查找,不区分大小写
-mtime +/-n#-n表示n天以内修改的文件,+n表示修改超过n天的文件
-user#按文件属主查找
-size [+/-]n[c/k/M/G]#查找文件长度为n块,+表示大于,-表示小于;c是字节
-perm权限数值 #按照文件权限进行查找
-maxdepth N#查找的目录深度
-ls#以列表形式显示
-type [f/d/l]# 按类型查看
-exec执行shell命令,形式: -exec command {} ;

查找举例

命令说明
find / -name “文件名”#从根目录查找指定文件名的文件,如果不指定目录,则从当前目录查找
find . -name “文件名”#从当前目录查找指定文件名的文件
find -name “文件名”#从当前目录查找指定文件名的文件
find 绝对路径 -name “2.txt”#查找指定目录下的文件
find /tools -mtime -3#查找tools目录下修改时间是3天以内的文件
find /tools -mtime +3#查找tools目录下修改时间是3天以上的文件
find /tools -size 12c#查找长度为12字节的文件
find /var -size +10k -size -100k -name ‘*.log’#在/var目录下,查找10-100k
find -maxdepth 1 -user root#按文件的所属用户查找
find . -name ‘*.txt’ -exec rm {} ;#删除当前目录及其子目录下的所有后缀为txt的文件,注意{}和\中间有空格,最后有一个;
find -perm 700 -maxdepth 1 -ls#只查找当前目录下,权限是700的文件,并以列表形式显示
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值