Comprehensive Guide to Understanding Linux Commands with Man Pages (linux man手册 英文)

Linux is a popular operating system that is often used by developers and IT professionals. One of the key features of Linux is its command-line interface, which allows users to interact with the operating system directly through a set of commands. While this can be intimidating for newcomers, Linux commands are easy to learn and can be a powerful tool for managing your system. In this comprehensive guide, we will explore how to use Linux commands with man pages to better understand and navigate your system.

What are man pages?

Before we dive into Linux commands, it is important to understand what man pages are. Man pages, short for “manual pages,” are help files that provide documentation for every command avlable in Linux. These files are generally installed by default with the operating system and can be accessed through the command line. Each man page contns a brief description of the command, its syntax, and a list of options and arguments. Man pages are an essential tool for understanding and using Linux commands.

How to access man pages

To access a man page, simply type “man” followed by the name of the command you want to learn about. For example, to access the man page for the “ls” command (which lists the contents of a directory), type:

man ls

This will open the man page for the ls command, which you can read through to learn more about how to use it. To exit the man page, press the “q” key.

Navigating man pages

Man pages can be long and complex, so it is important to know how to navigate them effectively. The man page is divided into several sections, each of which provides information on a different aspect of the command. The section numbers range from 1 to 9, with section 1 contning general user commands, and sections 2-9 contning system administration commands and programming interfaces.

To navigate through the man page, you can use the arrow keys to scroll up and down or use the spacebar to move down one page at a time. You can also search for specific keywords by typing “/” followed by the word you are looking for. The man page will highlight all instances of that word, making it easy to find what you need.

Using Linux commands

Now that you know how to access and navigate man pages, it’s time to start using Linux commands. Here are some basic commands to get you started:

1. ls

The “ls” command lists the contents of a directory. By default, it will list all files and directories in the current directory. You can also specify a different directory to list by including the path to that directory as an argument. For example:

ls /home/user/Documents

This will list all files and directories in the “/home/user/Documents” directory.

2. cd

The “cd” command allows you to change directories. To navigate to a specific directory, simply type “cd” followed by the path to that directory. For example:

cd /home/user/Documents

This will change the current directory to “/home/user/Documents”. You can also use “..” to move up one directory level:

cd ..

This will change the current directory to the parent directory.

3. mkdir

The “mkdir” command creates a new directory. To create a new directory, simply type “mkdir” followed by the name of the new directory. For example:

mkdir new_directory

This will create a new directory called “new_directory” in the current directory.

4. rm

The “rm” command removes files and directories. To remove a file, simply type “rm” followed by the name of the file you want to delete. For example:

rm file.txt

This will delete the file “file.txt”. If you want to delete a directory and all its contents, use the “-r” option:

rm -r directory/

This will delete the directory “directory” and all its contents.

Conclusion

Linux commands can seem daunting at first, but with the help of man pages, you can quickly learn how to navigate your system and perform a variety of tasks. By accessing man pages and using basic commands like ls, cd, mkdir, and rm, you can begin to explore the power of Linux and take control of your system. With practice and patience, you can become an expert in Linux commands and use them to streamline your workflow and become a more efficient developer or IT professional.

相关问题拓展阅读:

Linux命令大全

linux命令格式:

说明:command: 命令名,相应功能的英文单词或单词的缩写 :选项,可用来对命令进行控制,也可以省略,或激携代表可选 parameter1 …:传给命令的参数:可以是零个一个或多个

一般是linux命令自带的帮助信息

如:

man是linux提供的一个手册,包含了绝大部分的命令、函数使用说明

该手册分成很多章节(section),使用man时可以指定不同的章节来浏览。

例:man ls ; man 2 printf

man中各个section意义如下:

man是按照手册的章节号的顺序进行搜索的。

man设置了如下的衫伏功能键:

在敲出命令的前几个字母的同时,按下tab键,系统会自动帮我们补全命令

当系统执行过一些命令后,可按上下键翻看以前的命令,history将执行过的命令列举出来

ls是英文单词list的简写,其功能为列出目录的内容,是用户最常用的命令之一,它类似于DOS下的dir命令。

Linux文件或者目录名称最长可以有265个字符,“.”代表当前目录,“..”代表上一级目录,以“.”开头的文件为隐藏文件,需要用 -a 参数才能显示。

ls常用参数:

Linux允许将命令执行结果重定向到一个文件,本应显示在终端上的内容保存到指定文件中。

如:ls > test.txt ( test.txt 如果不存在,则创建,存在则覆盖其内容 )

注意: >输出重定向会覆盖原来的内容,>>输出重定向则会追加到文件的尾部。

查看内容时,在信息过长无法在一屏上显示时,会出现快速滚屏,使得用户无法看清文件的内容,此时可以使用more命令,每次只显示一页,按下空格键可以显示下一页,按下q键退出显示,按下h键可以获取帮助。

管道:一个命令的输出可以通过管道做为另一个命令的输入。

管道我们可以理解现实生活中的管子,管子的一头塞东西进去,另一头取出来,这里“ | ”的左右分为两端,左端塞东西(写),右端取东西(读)。

clear作用为清除终端上的显示(类似于DOS的cls清屏功能),也可使用快捷键:Ctrl + l ( “l” 为字母 )。

在使用Unix/Linux的时候,经常需要更换工作目录。cd命令可以帮助用户切换工作目录。Linux所有的目录和文件名大小写敏感

cd后铅弊面可跟绝对路径,也可以跟相对路径。如果省略目录,则默认切换到当前用户的主目录。

使用pwd命令可以显示当前的工作目录,该命令很简单,直接输入pwd即可,后面不带参数。

通过mkdir命令可以创建一个新的目录。参数-p可递归创建目录。

需要注意的是新建目录的名称不能与当前目录中已有的目录或文件同名,并且目录创建者必须对当前目录具有写权限。

可使用rmdir命令删除一个目录。必须离开目录,并且目录必须为空目录,不然提示删除失败。

可通过rm删除文件或目录。使用rm命令要小心,因为文件删除后不能恢复。为了防止文件误删,可以在rm后使用-i参数以逐个确认要删除的文件。

常用参数及含义如下表所示:

Linux链接文件类似于Windows下的快捷方式。

链接文件分为软链接和硬链接。

软链接:软链接不占用磁盘空间,源文件删除则软链接失效。

硬链接:硬链接只能链接普通文件,不能链接目录。

使用格式:

如果没有-s选项代表建立一个硬链接文件,两个文件占用相同大小的硬盘空间,即使删除了源文件,链接文件还是存在,所以-s选项是更常见的形式。

注意:如果软链接文件和源文件不在同一个目录,源文件要使用绝对路径,不能使用相对路径。

Linux系统中grep命令是一种强大的文本搜索工具,grep允许对文本文件进行模式查找。如果找到匹配模式, grep打印包含模式的所有行。

grep一般格式为:

在grep命令中输入字符串参数时,更好引号或双引号括起来。例如:grep‘a ’1.txt。

常用选项说明:

find命令功能非常强大,通常用来在特定的目录下搜索符合条件的文件,也可以用来搜索特定用户属主的文件。

常用用法:

cp命令的功能是将给出的文件或目录复制到另一个文件或目录中,相当于DOS下的copy命令。

常用选项说明:

用户可以使用mv命令来移动文件或目录,也可以给文件或目录重命名。

常用选项说明:

计算机中的数据经常需要备份,tar是Unix/Linux中最常用的备份工具,此命令可以把一系列文件归档到一个大文件中,也可以把档案文件解开以恢复数据。

tar使用格式 tar 打包文件名 文件

tar命令很特殊,其参数前面可以使用“-”,也可以不使用。

常用参数:

tar与gzip命令结合使用实现文件打包、压缩。 tar只负责打包文件,但不压缩,用gzip压缩tar打包后的文件,其扩展名一般用x.tar.gz。

gzip使用格式如下:

gzip 被压缩文件

常用选项:

tar与bzip2命令结合使用实现文件打包、压缩(用法和gzip一样)。

tar只负责打包文件,但不压缩,用bzip2压缩tar打包后的文件,其扩展名一般用x.tar.gz2。

在tar命令中增加一个选项(-j)可以调用bzip2实现了一个压缩的功能,实行一个先打包后压缩的过程。

压缩用法:tar -jcvf 压缩包包名 文件…(tar jcvf bk.tar.bz2 *.c)

解压用法:tar -jxvf 压缩包包名 (tar jxvf bk.tar.bz2)

通过zip压缩文件的目标文件不需要指定扩展名,默认扩展名为zip。

压缩文件:zip 目标文件(没有扩展名) 源文件

解压文件:unzip -d 解压后目录文件 压缩文件

whoami该命令用户查看当前系统当前账号的用户名。可通过cat /etc/passwd查看系统用户信息。

由于系统管理员通常需要使用多种身份登录系统,例如通常使用普通用户登录系统,然后再以su命令切换到root身份对传统进行管理。这时候就可以使用whoami来查看当前用户的身份。

who命令用于查看当前所有登录系统的用户信息。

常用选项:

如果是图形界面,退出当前终端;

如果是使用ssh远程登录,退出登陆账户;

如果是切换后的登陆用户,退出则返回上一个登陆账号。

在Unix/Linux中添加用户账号可以使用adduser或useradd命令,因为adduser命令是指向useradd命令的一个链接,因此,这两个命令的使用格式完全一样。

useradd命令的使用格式如下:

useradd 新建用户账号

在Unix/Linux中,超级用户可以使用passwd命令为普通用户设置或修改用户口令。用户也可以直接使用该命令来修改自己的口令,而无需在命令后面使用用户名。

可以通过su命令切换用户,su后面可以加“-”。su和su –命令不同之处在于,su -切换到对应的用户时会将当前的工作目录自动转换到切换后的用户主目录:

注意:如果是ubuntu平台,需要在命令前加“sudo”,如果在某些操作需要管理员才能操作,ubuntu无需切换到root用户即可操作,只需加“sudo”即可。sudo是ubuntu平台下允许系统管理员让普通用户执行一些或者全部的root命令的一个工具,减少了root 用户的登陆和管理时间,提高了安全性。

方法一:

方法二:

groupadd 新建组账号 groupdel 组账号 cat /etc/group 查看用户组

使用方法:usermod -g 用户组 用户名

新创建的用户,默认不能sudo,需要进行一下操作

-g用来制定这个用户默认的用户组

-G一般配合’-a’来完成向其它组添加

chmod 修改文件权限有两种使用格式:字母法与数字法。

字母法:chmod u/g/o/a +/-/= rwx 文件

cal命令用于查看当前日历,-y显示整年日历

设置时间格式(需要管理员权限):

date YY>> +format

CC为年前两位yy为年的后两位,前两位的mm为月,后两位的mm为分钟,dd为天,hh为小时,ss为秒。如: date.55。

显示时间格式(date ‘+%y,%m,%d,%H,%M,%S’):

进程是一个具有一定独立功能的程序,它是操作系统动态执行的基本单元。

ps命令可以查看进程的详细状况,常用选项(选项可以不加“-”)如下:

top命令用来动态显示运行中的进程。top命令能够在运行后,在指定的时间间隔更新显示信息。可以在使用top命令时加上-d 来指定显示信息更新的时间间隔。

在top命令执行后,可以按下按键得到对显示的结果进行排序:

kill命令指定进程号的进程,需要配合 ps 使用。有些进程不能直接杀死,这时候我们需要加一个参数“ -9 ”,“ -9 ” 代表强制结束.

使用格式:

kill pid

df命令用于检测文件系统的磁盘空间占用和空余情况,可以显示所有文件系统对节点和磁盘块的使用情况。

du命令用于统计目录或文件所占磁盘空间的大小,该命令的执行结果与df类似,du更侧重于磁盘的使用状况。

du命令的使用格式如下: du 目录或文件名

linux 设置中文版man手册

操滚李型作系统为centos7

cd ~

vi .bash_profile

alias cman=’man -M /usr/local/share/扰桥man/zh_CN’

source .bash_profile #更新bash_profile 使大猜其生效

关于linux man手册 英文的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。


数据运维技术 » Comprehensive Guide to Understanding Linux Commands with Man Pages (linux man手册 英文)