文件系统结构
树形
●/bin: bin是二进制( binary )英文缩写。
●/ boot : 存放的都是系统启动时要用到的程序。
●/dev:包含了所有Linux系统中使用的外部设备。
●/etc: 存放了系统管理时要用到的各种配置文件和子目录
●/lib存放系统动态连接共享库的。
●/ home :普通用户的主目录
●/root:根用户(超级用户)的主目录
命令
pwd
man pwd
ctrl+shift+t 切换标签
ctrl+l 清屏
ls
-a
不隐藏一点开头文件
-l
-R 递归显示子目录
cyz@cyz-virtual-machine:~/桌面/testcpp$ ls -R
.:
21-3.cpp 36-1.cpp 55 IntArray.cpp t1.cpp test.cpp
23-1.cpp 36-2.cpp 61-70 IntArray.h t2.cpp test.h
27-1.cpp 36-3.cpp 67-0.cpp main.cpp t3.cpp test.out
3-1test.cpp 50-1.cpp a.out singleton test.c tt
./55:
55-3.cpp a.out
./61-70:
65-1.cpp a.out
./singleton:
a.out main.cpp Singleton.h
./tt:
a.out IntArray.cpp IntArray.h main.cpp
cyz@cyz-virtual-machine:~/桌面/testcpp$ ls -r
tt test.c singleton a.out 50-1.cpp 3-1test.cpp
test.out t3.cpp main.cpp 67-0.cpp 36-3.cpp 27-1.cpp
test.h t2.cpp IntArray.h 61-70 36-2.cpp 23-1.cpp
test.cpp t1.cpp IntArray.cpp 55 36-1.cpp 21-3.cpp
cyz@cyz-virtual-machine:~/桌面/testcpp$ ls -R 55
55:
55-3.cpp a.out
mkdir 建立文件夹
cd… 返回上一级
cp
文件的权限
权限:创建者 同组用户 其他用户
linux文件系统与windows的差异
插优盘 新增目录
df - report file system disk space usage
SYNOPSIS
df [OPTION]… [FIL
df -T
查看 复制 移动 删除
cat
-s 空行合并-s, --squeeze-blank
suppress repeated empty output lines
-b 加行号显示-b, --number-nonblank
number nonempty output lines, overrides -n
nl nl - number lines of files
head
tail
复制
改名复制
不改名复制
linux@linux:~$ cp test.c test2.c
linux@linux:~$ pwd
/home/linux
linux@linux:~$ cp test.c ../
cp: cannot create regular file ‘../test.c’: Permission denied
linux@linux:~$ mkdir t
linux@linux:~$ cp test.c /t
cp: cannot create regular file ‘/t’: Permission denied
linux@linux:~$ cp test.c /home/linux/t
linux@linux:~$ cd t
linux@linux:~/t$ vi tt.c
linux@linux:~/t$ cat tt.c
#include <stdio.h>
int main(int argc, const char *argv[])
{
printf("kkk\n");
return 0;
}
linux@linux:~/t$ pwd
/home/linux/t
linux@linux:~/t$ cp tt.c ../
cp -r
-R, -r, --recursive
copy directories recursively
mv
移动 重命名
touch 创建 改时间戳
rm - remove files or directories
-i -i prompt before every removal
-r -r, -R, --recursive
remove directories and their contents recursively
linux@linux:~/t$ mkdir pack/di/d2
mkdir: cannot create directory ‘pack/di/d2’: No such file or directory
linux@linux:~/t$ mkdir -p pack/di/d2
linux@linux:~/t$ ls -r
tt.c pack
linux@linux:~/t$ ls -R pack
pack:
di
pack/di:
d2
mkdir
-p
rm
-r
VI编辑器
模式
命令行
无法编辑 a i o命令
插入模式
底行
I 光标跑到行首位置
a适用于 缺少分号的场景
A 跑到行尾
o下方插入新行
O上方插入新行
忘记当前目录 先ESC,在输入 !pwd,可以看到目录,回车返回VI
用于命令行模式
(dd,yy,p,P)以行为单位
复制光标一下7行,先输入7yy,移动光标到要粘贴的位置,按p
p在光标下面
P在光标上面
以字符为单位x
x等价于wq
w test2.c另存为
r 用于引入头文件,例子#include
光标命令
VI编辑器的切换 (默认:命令行)
查找/
例如查找printf
/printf
:s的字符串替换
str1替换成str2
范围s/old/new 不写范围:就是当前行
,$ s 当前行到末尾行
1,$ (%)s全文
10,15s 10到15行
g 符合的全替换,默认只换第一个 global
块复制(???)
:118,119y
:118,120d
程序的编译和调试
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ gcc 1.c -o 1
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ ls
1 11.c 1.c a b cpdir cpr s.h test
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ ls -l
总计 44
-rwxrwxr-x 1 cyz cyz 15960 8月 10 16:17 1
-rw-rw-r-- 1 cyz cyz 299 8月 10 14:02 11.c
-rw-rw-r-- 1 cyz cyz 162 8月 10 16:16 1.c
-rw-rw-r-- 1 cyz cyz 0 8月 10 13:37 a
drwxrwxr-x 2 cyz cyz 4096 8月 10 13:37 b
drwxrwxr-x 3 cyz cyz 4096 8月 10 13:48 cpdir
drwxrwxr-x 3 cyz cyz 4096 8月 10 13:49 cpr
-rw-rw-r-- 1 cyz cyz 17 8月 10 14:03 s.h
drwxrwxr-x 2 cyz cyz 4096 8月 10 13:34 test
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ ./1
hello,ubuntu,08.10
hello,08.10linux
hello,08.10linux
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ cat 1.c
#include<stdio.h>
#include<math.h>
int main()
{
printf("hello,ubuntu,08.10\n");
printf("hello,08.10linux\n");
printf("hello,08.10linux\n");
return 0;
}
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ gcc 1.c -o 1 -wall //不用-o指定名字,默认a.out
gcc: error: unrecognized command-line option ‘-wall’; did you mean ‘-Wall’?
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ gcc 1.c -o 1 -Wall
ctrl+shift+N 开窗口
ctrl+shift+T :开标签
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ gcc 1.c -Wall
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ ./a.out
1+2+...+100=5050
main,1.c,12
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ man cat
cyz@cyz-virtual-machine:~/桌面/testcpp/VIlearning$ cat -s 1.c
#include<stdio.h>
#include<math.h>
int main()
{
int res=0;
int i=0;
for(i=0;i<=100;i++)
{
res+=i;
}
printf("1+2+...+100=%d\n",res);
printf("%s,%s,%d\n",__FUNCTION__,__FILE__,__LINE__);
return 0;
}
-wall 多显示警告