linux常用命令学习

sh-# ls /test_dir/
test_file
sh-# ls -lh /test_dir/
total 0
-rw-r--r-- 1 root root 0 Jan  1 00:02 test_file
sh-# echo "my file" > /test_dir/test_file
sh-# cat /test_dir/test_file
my file
sh-# cp /test_dir/test_file /test_dir/new_file
sh-# ls -lh /test_dir/
total 8.0K
-rw-r--r-- 1 root root 8 Jan  1 00:03 new_file
-rw-r--r-- 1 root root 8 Jan  1 00:02 test_file
sh-# rm -f /test_dir/
rm: cannot remove `/test_dir/': Is a directory
sh-# rm -rf /test_dir/
sh-# busybox which ls
/bin/ls
sh-# mkdir /new_dir
sh-# rmdir /new_dir/
sh: rmdir: command not found
sh-# busybox rmdir /new_dir/
rmdir: applet not found
sh-# ps aux | grep my_process
root      1140  0.0  0.1   1728   544 ?        S+   00:09   0:00 grep my_process
sh-# kill -9 10000
sh: kill: (10000) - No such process
sh-# mkdir /new_dir
mkdir: cannot create directory `/new_dir': File exists
sh-# rm -rf /new_dir/
sh-# mkdir /new_dir
/new_dir/new_file
sh-# ls -lh /new_dir/
total 0
-rw-r--r-- 1 root root 0 Jan  1 00:10 new_file
sh-# echo "new file" > /new_dir/new_file
sh-# cat /new_dir/new_file
new file
sh-# cp /new_dir/new_file /new_dir/new_file_2
sh-# ls -lh /new_dir/
total 8.0K
-rw-r--r-- 1 root root 9 Jan  1 00:10 new_file
-rw-r--r-- 1 root root 9 Jan  1 00:11 new_file_2
sh-# busybox which ls
/bin/ls
sh-# busybox whereis ls
whereis: applet not found
sh-# history
    1  ps aux | grep mp_proce
    2  ps aux | grep my_process
    3  kill -9 854
    4  ps aux | grep mp_process
    5  kill -9 854
    6  mkdir /test_dir
    7  touch /test_dir/test_file
    8  ls /test_dir/
    9  ls -lh /test_dir/
   10  echo "my file" > /test_dir/test_file
   11  cat /test_dir/test_file
   12  cp /test_dir/test_file /test_dir/new_file
   13  ls -lh /test_dir/
   14  rm -f /test_dir/
   15  rm -rf /test_dir/
   16  busybox which ls
   17  mkdir /new_dir
   18  rmdir /new_dir/
   19  busybox rmdir /new_dir/
   20  history
   21  ps aux | grep my_process
   22  kill -9 10000
   23  mkdir /new_dir
   24  rm -rf /new_dir/
   25  mkdir /new_dir
   26  touch /new_dir/new_file
   27  ls -lh /new_dir/
   28  echo "new file" > /new_dir/new_file
   29  cat /new_dir/new_file
   30  cp /new_dir/new_file /new_dir/new_file_2
   31  ls -lh /new_dir/
   32  busybox which ls
   33  busybox whereis ls
   34  history
sh-# busybox vi /new_dir/new_file
sh-# type ls
ls is hashed (/bin/ls)
sh-# type type
type is a shell builtin
sh-# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 2303
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 2303
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

sh-# id
sh: id: command not found
sh-# busybox id
uid=0(root) gid=0(root)
sh-#
sh-# cp /new_dir/ /new_dir_1
cp: omitting directory `/new_dir/'
sh-# cp -r /new_dir/ /new_dir_1
sh-# ls -lh /new_dir*
/new_dir:
total 8.0K
-rw-r--r-- 1 root root 9 Jan  1 00:10 new_file
-rw-r--r-- 1 root root 9 Jan  1 00:11 new_file_2

/new_dir_1:
total 8.0K
-rw-r--r-- 1 root root 9 Jan  1 00:33 new_file
-rw-r--r-- 1 root root 9 Jan  1 00:33 new_file_2
sh-# pwd
/
sh-# cd /new_dir
sh-# pwd
/new_dir
sh-# mv /new_dir/new_file /new_dir_1/
sh-# ls -lh /new_dir_1/new_file
-rw-r--r-- 1 root root 9 Jan  1 00:10 /new_dir_1/new_file
sh-# chmod 755 /new_dir_1/new_file
sh-# ls -lh /new_dir_1/new_file
-rwxr-xr-x 1 root root 9 Jan  1 00:10 /new_dir_1/new_file
sh-# locate
sh: locate: command not found
sh-# mkdir /new_dir/new_dir_2
sh-# cd /new_dir/new_dir_2/
sh-# pwd | xargs
/new_dir/new_dir_2
sh-# pwd | xargs basename
new_dir_2
sh-# pwd | xargs dirname
/new_dir
sh-# set
BASH=/bin/sh
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()

补充两点:

1. 常用的linux命令远不止于此,这只是九牛一毛冰山一角,后续会陆陆续续将自己用到的补上来;

2. 很多linux命令功能非常强大,不需要刻意的去记下各个命令的用法,在需要时查资料即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值