Ubuntu terminal common commands (linux common commands)

Open Terminal shortcut

On any empty space on the desktop, hit ctrl+alt+t

The linux text compiler vi uses


Text Compiler Common Commands

In command mode, you can use the following two keys to enter text input mode:
a: Add text after the current cursor.
A: Add text at the end of the line where the current cursor is located.
i: Add text before the current cursor.
I: Add text at the beginning of the line where the current cursor is located.
o: Add a line below the current cursor line and add text at the beginning of the new line.
In the input mode, if the user wants to return to the command mode, he can only use the Esc key to switch to the command mode in the input mode, and then the cursor will appear at the bottom of the screen to wait for the input command.


1.vi startup

After entering the vi command, it will enter the full-screen editing environment, and the state at this time is the command mode.

vi file1

If the file1 file does not exist, it will be created; if the file exists, it will be copied to a temporary buffer. The cursor is positioned at row 1 and column 1 of the buffer.

2. Exit vi

It is recommended to press the ESC key before exiting vi to ensure that the current state of vi is in command mode, and then type ":" ( colon ) , enter the following commands, such as ( exit ), to exit vi .

3. Delete

x : delete the character after the current cursor position. x

#x : Delete # characters after the current cursor position. For example, 5x means delete 5 characters.

dd : delete the line where the current cursor is located.

#dd : Delete the # line after the current cursor . For example, 5dd means to delete 5 lines from the cursor .

:l,#d : For example, :1,12d means to delete text from line 1 to line 12 .

X : Delete the left character of the current cursor.

D : Delete to the end of the line.

4. Change

cw : Change the word at the cursor to the end of the word.

c#w : For example, c3w means change 3 words.

cc : Modify the line.

C : Replace to end of line.

5. to replace

r : Replace the character at the cursor.

R : Substitute characters until ESC is pressed .

6. Copy

yw : Copy the word at the cursor to the end of the word to the buffer.

P : Read the contents of the vi buffer and paste it to the current position of the cursor (without overwriting the existing contents of the file).

yy : Copy the entire content of the current line to the vi buffer.

#yy : For example , 5yy , copy 5 lines below the cursor position to the buffer.

7. Recovery

u : Revert to the previous operation.

g : List the line number, and related information.

8. List line numbers

:setnu (nu is the number of lines )

9. Find Strings

/word Search for the " word" string from the beginning to the end, press n to continue to search down.

?word由尾至首寻找“word”字符串,按N可往前继续找。

10.跳行

:100可跳至第100行。

11.重复上一个命令

.重复上一个命令。


Linux常用命令(终端中操作)
:w test    //保存为文件名为test的文件
:wq // 退出并保存当前文件
ls  显示
ls –l 显示文件夹内文件详细信息,也可用ll
ls –a 显示文件夹内隐藏文件
ls ~  显示用户宿主目录
man 查看命令帮助文档
man ls
touch 创建文件
touch a.txt
rm  删除文件

cd 切换目录
cd .. 退出当前目录回到上一级目录
cd /  切换到根目录
cd /root/xx  切换到一个子目录下
cd ~ 切换到用户的宿主目录
mkdir 新建目录
rmdir 删除一个空目录
cp 拷贝
cp /root/a.txt /soft/ab 拷贝一个文件到一个目录中
cp /root/*.mp3 /soft/ab 拷贝扩展名为mp3的所有文件
cp –r /root /soft/ab 拷贝一个目录到另一个目录
cp –r –f /root /soft/ab 拷贝一个目录到另一个目录, 同时删除前面已经存在的目录
rm 删除文件/目录
rm –f 删除文件时不提示警告
rm –r 递归删除,常用于删除目录
如:rm –fr /root/xx 表示删除xx目录中所有文件与目录不提示
cat 查看文件内容
如:cat /etc/ab/x.txt 查看文件x.txt中内容
more 分屏显示
ls /etc |more 让/etc中文件与目录分屏显示
date 查看/修改日期和时间
date –s 月/日/四位年
date –s 时/分/秒
如:date –s 16:12:10.2v
15.less查看多内容的文件
   如:less /etc/squid/squid.conf 表示看squid.conf中内容分屏看.
16.pwd 显示当前所在位置
17.grep 过滤
   如:rpm –qa|grep httpd 查看系统中是否装了apache软件
18.> 导出文件
   如:ls /etc > /root/a.txt 把/etc下所有文件名存入a.txt
19.find 查找文件
   如:find –name “*.mp3” 查找当前目录中所有mp3文件
20.uptime 显示系统运行时长
21.df 显示磁盘占有空间
   df –T 显示磁盘占有空间与文件系统类型
22.cal 显示日历
23.mv 移动文件/目录或重命名
   如:mv /root/abc.jpg /etc/kk
   如:mv at.doc abc.doc
   如:mv kk.zip .kk.zip 表示隐藏文件
   如:mv .kk.zip kk.zip 去除隐藏
24.tree 显示树状目录
25.du 看磁盘使用情况
26.mkfs 创建文件系统  如:mkfs –t ext2 /mnt/floppy格式化软盘




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325890720&siteId=291194637