目录
Linux基础知识总结(命令行)
实验机器操作系统的发行编号:4.4.0-142-generic
man(手册工具)
man <输入想查询的工具>
uname(查看系统相关信息)
选项
使用上面提到的我们可以看到uname的具体用法,那么让我们来各个学习。
名称
uname - 打印系统信息
用法
uname [选项]...
描述
打印出系统信息
-a, --all
打印出全部信息
-s, --kernel-name
打印出内核的名称
-n, --nodename
打印出网络端点hostname
-r, --kernel-release
打印出操作系统编号
-v, --kernel-version
打印出内核版本
-m, --machine
打印出机器硬件
-p, --processor
打印出处理器名称或者unknown
-i, --hardware-platform
打印出硬件平台名称或"unknown"
-o, --operating-system
打印出操作系统名称
--version
打印出版本信息
例子
xx@xx:~$ uname -a
Linux xx 4.4.0-142-generic #168~14.04.1-Ubuntu SMP Sat Jan 19 11:26:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
xx@xx:~$ uname -s
Linux
xx@xx:~$ uname -n
xx
xx@xx:~$ uname -r
4.4.0-142-generic
xx@xx:~$ uname -v
#168~14.04.1-Ubuntu SMP Sat Jan 19 11:26:28 UTC 2019
xx@xx:~$ uname -m
x86_64
xx@xx:~$ uname -p
x86_64
xx@xx:~$ uname -i
x86_64
xx@xx:~$ uname -o
GNU/Linux
pwd(查看当前路径)
选项
名称
pwd - 打印当前地址
用法
pwd [选项]...
描述
打印当前用户所在地址.
-L, --logical
从环境中使用PWD,含有软链接
-P, --physical
物理地址,没有软连接
--version
打印工具版本
例子
xx@xx:~$ pwd -L
/home/xx
xx@xx:~$ pwd -P
/home/xx
cd(改变当前所在位置)
cd可以改变当前用户所在的路径位置。
例子
相对路径:我们可以用pwd查看当前位置,然后ls查看当前路径下的所有文件,然后cd [文件夹名]就可以进入到这个文件夹啦
xx@xx:~/Documents$ pwd
/home/xx/Documents
xx@xx:~/Documents$ ls
folder1
xx@xx:~/Documents$ cd folder1/
xx@xx:~/Documents/folder1$ pwd
/home/xx/Documents/folder1
xx@xx:~/Documents/folder1$
绝对路径:如果想去一个绝对路径,那么可以 cd [绝对路径]
xx@xx:~$ cd /home/xx/Documents/folder1/
xx@xx:~/Documents/folder1$ pwd
/home/xx/Documents/folder1
返回用户根目录:cd ~ 可以带你回到当前用户的根目录
xx@xx:~/Documents/folder1$ pwd
/home/xx/Documents/folder1
xx@xx:~/Documents/folder1$ cd ~
xx@xx:~$ pwd
/home/xx
cat(显示文件内容)
选项
名称
cat - 将文件打印至屏幕
用法
cat [选项]... [文件]...
描述
将文件(们)打印至standard input或者standard output,也就是STDIN,STDOUT
-A, --show-all
显示全部,也可以使用(-vET)
-b, --number-nonblank
显示内容加上行数(忽略空白行)
-e
是-vE的简写
-E, --show-ends
在每一行的末尾加上$,为了让我们更方便看出来\n
-n, --number
显示内容加上行数(不忽略空白行)
-s, --squeeze-blank
显示除空白行之外的内容
-t
是-vT的简写
-T, --show-tabs
将Tab符号显示成^I
-v, --show-nonprinting
use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version
output version information and exit
例子
显示内容加上行数(忽略空白行) cat -b fork.c
xx@xx:~/linux$ cat -b fork.c
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <unistd.h>
4 int main()
5 {
6 printf("Program Start\n");
7 fork();
8 fork();
9 printf("hello from: %d, my parent is: %d\n", getpid(), getppid());
10 sleep(1);
11 return 0;
12 }
xx@xx:~/linux$
显示内容加上行数(不忽略空白行) cat -n fork.c
xx@xx:~/linux$ cat -n fork.c
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <unistd.h>
4 int main()
5 {
6 printf("Program Start\n");
7 fork();
8 fork();
9 printf("hello from: %d, my parent is: %d\n", getpid(), getppid());
10 sleep(1);
11 return 0;
12 }
13
14
15
xx@xx:~/linux$
在每一行的末尾加上$,为了让我们更方便看出来\n
xx@xx:~/linux$ cat -E fork.c
#include <stdio.h>$
#include <sys/types.h>$
#include <unistd.h>$
int main()$
{$
printf("Program Start\n");$
fork(); $
fork();$
printf("hello from: %d, my parent is: %d\n", getpid(), getppid());$
sleep(1);$
return 0; $
}$
$
$
$
xx@xx:~/linux$
将Tab符号显示成 ^I
xx@xx:~/linux$ cat -T fork.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
^Iprintf("Program Start\n");
^Ifork();
^Ifork();
^Iprintf("hello from: %d, my parent is: %d\n", getpid(), getppid());
^Isleep(1);
^Ireturn 0;
}
xx@xx:~/linux$
显示全部
xx@xx:~/linux$ cat -A fork.c
#include <stdio.h>$
#include <sys/types.h>$
#