C language programming in Linux

Source: Internet
Author: User
Tags gz file
Learn about C language programming in Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. 1. How to view all commands?
Familiarity with Linux commands is a necessary process to facilitate and quickly work in Linux. How can we know all the commands from the common ls commands?

First, use the which command to obtain the path of the ls command:
Which ls

The command output is as follows:/usr/bin/ls

Then, check which package provides the/usr/bin/ls file. Run the following command: dpkg-S/usr/bin/ls.

The command output is as follows: coreutils:/usr/bin/split

Finally, check the full content of the coreutils package: dpkg-L coreutils

The command output is as follows :/.
/Bin
/Bin/cat
/Bin/chgrp
/Bin/chmod
/Bin/chown
/Bin/cp
/Bin/date
/Bin/dd
/Bin/df
/Bin/dir
/Bin/echo
/Bin/false
/Bin/ln
/Bin/ls
/Bin/mkdir
/Bin/mknod
/Bin/mv
/Bin/pwd
/Bin/readlink
/Bin/rm
/Bin/rmdir
/Bin/vdir
/Bin/sleep
/Bin/stty
/Bin/sync
/Bin/touch
/Bin/true
/Bin/uname
/Sbin
/Usr
/Usr/share
/Usr/share/doc
/Usr/share/doc/coreutils
/Usr/share/doc/coreutils/AUTHORS
/Usr/share/doc/coreutils/THANKS.gz
/Usr/share/doc/coreutils/TODO.gz
/Usr/share/doc/coreutils/THANKS-to-translators
/Usr/share/doc/coreutils/buildinfo.gz
/Usr/share/doc/coreutils/NEWS.Debian.gz
/Usr/share/doc/coreutils/changelog.gz
/Usr/share/doc/coreutils/README. Debian
/Usr/share/doc/coreutils/copyright
/Usr/share/doc/coreutils/NEWS.gz
/Usr/share/doc/coreutils/README.gz
/Usr/share/doc/coreutils/changelog.Debian.gz
/Usr/share/info
/Usr/share/info/coreutils.info.gz
/Usr/share/man
/Usr/share/man/man1
/Usr/share/man/man1/cat.1.gz
/Usr/share/man/man1/chgrp.1.gz
/Usr/share/man/man1/chown.1.gz
/Usr/share/man/man1/cksum.1.gz
/Usr/share/man/man1/comm.1.gz
/Usr/share/man/man1/cp.1.gz
/Usr/share/man/man1/cut.1.gz
/Usr/share/man/man1/date.1.gz
/Usr/share/man/man1/dd.1.gz
/Usr/share/man/man1/df.1.gz
/Usr/share/man/man1/dir.1.gz
/Usr/share/man/man1/dirname.1.gz
/Usr/share/man/man1/du.1.gz
/Usr/share/man/man1/echo.1.gz
/Usr/share/man/man1/env.1.gz
/Usr/share/man/man1/expand.1.gz
/Usr/share/man/man1/expr.1.gz
/Usr/share/man/man1/factor.1.gz
/Usr/share/man/man1/fmt.1.gz
/Usr/share/man/man1/fold.1.gz
/Usr/share/man/man1/groups.1.gz
/Usr/share/man/man1/head.1.gz
/Usr/share/man/man1/hostid.1.gz
/Usr/share/man/man1/id.1.gz
/Usr/share/man/man1/chmod.1.gz
/Usr/share/man/man1/join.1.gz
/Usr/share/man/man1/link.1.gz
/Usr/share/man/man1/ln.1.gz
/Usr/share/man/man1/logname.1.gz
/Usr/share/man/man1/ls.1.gz
/Usr/share/man/man1/md5sum.1.gz
/Usr/share/man/man1/mkdir.1.gz
/Usr/share/man/man1/mkw.o.1.gz
/Usr/share/man/man1/mknod.1.gz
/Usr/share/man/man1/mv.1.gz
/Usr/share/man/man1/nl.1.gz
/Usr/share/man/man1/nohup.1.gz
/Usr/share/man/man1/od.1.gz
/Usr/share/man/man1/pathchk.1.gz
/Usr/share/man/man1/pinky.1.gz
/Usr/share/man/man1/pr.1.gz
/Usr/share/man/man1/printenv.1.gz
/Usr/share/man/man1/printf.1.gz
/Usr/share/man/man1/ptx.1.gz
/Usr/share/man/man1/pwd.1.gz
/Usr/share/man/man1/rm.1.gz
/Usr/share/man/man1/rmdir.1.gz
/Usr/share/man/man1/seq.1.gz
/Usr/share/man/man1/sha1sum.1.gz
/Usr/share/man/man1/shred.1.gz
/Usr/share/man/man1/sleep.1.gz
/Usr/share/man/man1/sort.1.gz
/Usr/share/man/man1/stat.1.gz
/Usr/share/man/man1/stty.1.gz
/Usr/share/man/man1/sum.1.gz
/Usr/share/man/man1/sync.1.gz
/Usr/share/man/man1/tac.1.gz
/Usr/share/man/man1/tail.1.gz
/Usr/share/man/man1/tee.1.gz
/Usr/share/man/man1/test.1.gz
/Usr/share/man/man1/touch.1.gz
/Usr/share/man/man1/tr.1.gz
/Usr/share/man/man1/tsort.1.gz
/Usr/share/man/man1/tty.1.gz
/Usr/share/man/man1/uname.1.gz
/Usr/share/man/man1/unexpand.1.gz
/Usr/share/man/man1/uniq.1.gz
/Usr/share/man/man1/users.1.gz
/Usr/share/man/man1/vdir.1.gz
/Usr/share/man/man1/wc.1.gz
/Usr/share/man/man1/who.1.gz
/Usr/share/man/man1/whoami.1.gz
/Usr/share/man/man1/yes.1.gz
/Usr/share/man/man1/chcon.1.gz
/Usr/share/man/man1/runcon.1.gz
/Usr/share/man/man1/basename.1.gz
/Usr/share/man/man1/csplit.1.gz
/Usr/share/man/man1/dircolors.1.gz
/Usr/share/man/man1/false.1.gz
/Usr/share/man/man1/install.1.gz
/Usr/share/man/man1/nice.1.gz
/Usr/share/man/man1/paste.1.gz
/Usr/share/man/man1/readlink.1.gz
/Usr/share/man/man1/split.1.gz
/Usr/share/man/man1/true.1.gz
/Usr/share/man/man1/unlink.1.gz
/Usr/share/man/man8
/Usr/share/man/man8/chroot.8.gz
/Usr/share/locale
/Usr/share/locale/af
/Usr/share/locale/af/LC_TIME
/Usr/share/locale/be
/Usr/share/locale/be/LC_TIME
/Usr/share/locale/bg
/Usr/share/locale/bg/LC_TIME
/Usr/share/locale/ca
/Usr/share/locale/ca/LC_TIME
/Usr/share/locale/cs
/Usr/share/locale/cs/LC_TIME
/Usr/share/locale/da
/Usr/share/locale/da/LC_TIME
/Usr/share/locale/de
/Usr/share/locale/de/LC_TIME
/Usr/share/locale/el
/Usr/share/locale/el/LC_TIME
/Usr/share/locale/es
/Usr/share/locale/es/LC_TIME
/Usr/share/locale/et
/Usr/share/locale/et/LC_TIME
/Usr/share/locale/eu
/Usr/share/locale/eu/LC_TIME
/Usr/share/locale/fi
/Usr/share/locale/fi/LC_TIME
/Usr/share/locale/fr
/Usr/share/locale/fr/LC_TIME
/Usr/share/locale/ga
/Usr/share/locale/ga/LC_TIME
/Usr/share/locale/gl
/Usr/share/locale/gl/LC_TIME
/Usr/share/locale/hr
/Usr/share/locale/hr/LC_TIME
/Usr/share/locale/hu
/Usr/share/locale/hu/LC_TIME
/Usr/share/locale/it
/Usr/share/locale/it/LC_TIME
/Usr/share/locale/ja
/Usr/share/locale/ja/LC_TIME
/Usr/share/locale/ko
/Usr/share/locale/ko/LC_TIME
/Usr/share/locale/lg
/Usr/share/locale/lg/LC_TIME
/Usr/share/locale/MS.
/Usr/share/locale/MS/LC_TIME
/Usr/share/locale/nb
/Usr/share/locale/nb/LC_TIME
/Usr/share/locale/nl
/Usr/share/locale/nl/LC_TIME
/Usr/share/locale/no
/Usr/share/locale/no/LC_TIME
/Usr/share/locale/pl
/Usr/share/locale/pl/LC_TIME
/Usr/share/locale/pt
/Usr/share/locale/pt/LC_TIME
/Usr/share/locale/pt_BR
/Usr/share/locale/pt_BR/LC_TIME
/Usr/share/locale/ru
/Usr/share/locale/ru/LC_TIME
/Usr/share/locale/rw
/Usr/share/locale/rw/LC_TIME
/Usr/share/locale/sk
/Usr/share/locale/sk/LC_TIME
/Usr/share/locale/sl
/Usr/share/locale/sl/LC_TIME
/Usr/share/locale/sv
/Usr/share/locale/sv/LC_TIME
/Usr/share/locale/tr
/Usr/share/locale/tr/LC_TIME
/Usr/share/locale/vi
/Usr/share/locale/vi/LC_TIME
/Usr/share/locale/zh_CN
/Usr/share/locale/zh_CN/LC_TIME
/Usr/share/locale/zh_TW
/Usr/share/locale/zh_TW/LC_TIME
/Usr/bin
/Usr/bin /[
/Usr/bin/dircolors
/Usr/bin/du
/Usr/bin/install
/Usr/bin/link
/Usr/bin/mkfifo
/Usr/bin/nohup
/Usr/bin/shred
/Usr/bin/stat
/Usr/bin/unlink
/Usr/bin/cksum
/Usr/bin/comm
/Usr/bin/csplit
/Usr/bin/cut
/Usr/bin/expand
/Usr/bin/fmt
/Usr/bin/fold
/Usr/bin/head
/Usr/bin/join
/Usr/bin/md5sum
/Usr/bin/nl
/Usr/bin/od
/Usr/bin/paste
/Usr/bin/pr
/Usr/bin/ptx
/Usr/bin/sha1sum
/Usr/bin/sort
/Usr/bin/split
/Usr/bin/sum
/Usr/bin/tac
/Usr/bin/tail
/Usr/bin/tr
/Usr/bin/tsort
/Usr/bin/unexpand
/Usr/bin/uniq
/Usr/bin/wc
/Usr/bin/basename
/Usr/bin/dirname
/Usr/bin/env
/Usr/bin/expr
/Usr/bin/factor
/Usr/bin/id
/Usr/bin/logname
/Usr/bin/pathchk
/Usr/bin/printenv
/Usr/bin/printf
/Usr/bin/seq
/Usr/bin/tee
/Usr/bin/test
/Usr/bin/tty
/Usr/bin/whoami
/Usr/bin/yes
/Usr/bin/chcon
/Usr/bin/runcon
/Usr/bin/hostid
/Usr/bin/nice
/Usr/bin/pinky
/Usr/bin/users
/Usr/bin/who
/Usr/bin/groups
/Usr/sbin
/Usr/sbin/chroot
/Usr/share/man/man1/developer.1.gz
/Usr/share/man/man1/md5sum.textutils.1.gz
/Usr/share/locale/af/LC_TIME/coreutils.mo
/Usr/share/locale/be/LC_TIME/coreutils.mo
/Usr/share/locale/bg/LC_TIME/coreutils.mo
/Usr/share/locale/ca/LC_TIME/coreutils.mo
/Usr/share/locale/cs/LC_TIME/coreutils.mo
/Usr/share/locale/da/LC_TIME/coreutils.mo
/Usr/share/locale/de/LC_TIME/coreutils.mo
/Usr/share/locale/el/LC_TIME/coreutils.mo
/Usr/share/locale/es/LC_TIME/coreutils.mo
/Usr/share/locale/et/LC_TIME/coreutils.mo
/Usr/share/locale/eu/LC_TIME/coreutils.mo
/Usr/share/locale/fi/LC_TIME/coreutils.mo
/Usr/share/locale/fr/LC_TIME/coreutils.mo
/Usr/share/locale/ga/LC_TIME/coreutils.mo
/Usr/share/locale/gl/LC_TIME/coreutils.mo
/Usr/share/locale/hr/LC_TIME/coreutils.mo
/Usr/share/locale/hu/LC_TIME/coreutils.mo
/Usr/share/locale/it/LC_TIME/coreutils.mo
/Usr/share/locale/ja/LC_TIME/coreutils.mo
/Usr/share/locale/ko/LC_TIME/coreutils.mo
/Usr/share/locale/lg/LC_TIME/coreutils.mo
/Usr/share/locale/MS/LC_TIME/coreutils.mo
/Usr/share/locale/nb/LC_TIME/coreutils.mo
/Usr/share/locale/nl/LC_TIME/coreutils.mo
/Usr/share/locale/no/LC_TIME/coreutils.mo
/Usr/share/locale/pl/LC_TIME/coreutils.mo
/Usr/share/locale/pt/LC_TIME/coreutils.mo
/Usr/share/locale/pt_BR/LC_TIME/coreutils.mo
/Usr/share/locale/ru/LC_TIME/coreutils.mo
/Usr/share/locale/rw/LC_TIME/coreutils.mo
/Usr/share/locale/sk/LC_TIME/coreutils.mo
/Usr/share/locale/sl/LC_TIME/coreutils.mo
/Usr/share/locale/sv/LC_TIME/coreutils.mo
/Usr/share/locale/tr/LC_TIME/coreutils.mo
/Usr/share/locale/vi/LC_TIME/coreutils.mo
/Usr/share/locale/zh_CN/LC_TIME/coreutils.mo
/Usr/share/locale/zh_TW/LC_TIME/coreutils.mo
/Usr/bin/md5sum. textutils
/Usr/bin/touch

From this we can see that the Linux system has more than 80 core commands, that is, the command files under the/bin and/usr/bin directories. At the same time, each command has a Help file in the system, that is, the files with the extension name gz under the/usr/share/man directory.
For example, in the above output, we can see a file/bin/cp, that is, we have a cp command that can be used. Which command is used for what purpose? You can open the/usr/share/man/man1/cp.1.gz file, but you don't need to open this file. Simply enter the following command:
Man 1 cp

2. man command usage
A major benefit of the Linux system is that it provides online help. Basically, everything has a document, and these documents and things are stored in the/usr/share directory.

The most basic one is man manual. All are in the/usr/share/man Directory, which is divided into man1, man2, man3. .. and other directories. That is, the man Manual chapter. The man1 directory contains the man Manual Chapter 1st, And the man2 directory contains the man Manual Chapter 2nd...

Man1-9 there are some files ending with gz in these directories. These files are our manuals, each file is a command name, a software tool name, or a function name. If you use the command man 1 cp, open the/usr/share/man/man1/cp.1.gz file to view the content. That is, the basic usage of the man command is man section-number pager.

Section-number indicates the number 1-9, and pager indicates the file name we see, that is, the name of a command or the name of a function.
Of course, the section-number here can be omitted. After the section-number is omitted, the man command will find the first suitable manual in a certain order. Section-number can also be-a to view the content of a name in all chapters.
Let's try man now. 1. Executable programs or shell commands. The first chapter is some Executable programs or shell commands.
2 System CILS (functions provided by the kernel) is the System call provided by the kernel.
3 Library CILS (functions within program libraries) is the Library function, which is quite useful for programming.
4 Special files (usually found in/dev) is the device file
5 File formats and conventions eg/etc/passwd: File Format and conversion method.
6 Games: Games
7 Miscellaneous (including macro packages and conven? \ R
Tions), e.g. man (7), and groff (7) are other tools.
8 System administration commands (usually only for root) is a number of System management commands.
9 Kernel routines [Non standard] is the Kernel function

3. Command Classification
It takes a lot of time to view the above 80 commands one by one. According to the instructions in the GNU manual info, these commands are divided into the following classes:
* Command for outputting the entire file content: cat tac nl od
* Command for formatting file content: fmt pr fold
* Command for outputting part of the file: head tail split csplit
* Command for statistic file information: wc sum cksum md5sum
* Command for operating the sorted files: sort uniq comm ptx tsort
* Run the command: cut paste join
* Character Operation Command: tr expand unexpand
* Command for displaying the directory content: ls dir vdir dircolors
* Command for basic operation: cp dd install mv rm shred
* Special File Operation Command: ln mkdir rmdir mkfifo mknod
* Command for changing file attributes: chgrp chmod chown touch
* Command for disk usage analysis: df du stat sync
* Command for printing text content: echo printf yes
* Conditional command: false true test expr
* Redirection command: tee
* File name Operation Command: dirname basename pathchk
* Commands related to the current working environment: pwd stty printenv tty
* Command related to user information: id logname whoami groups users who
* System command-related commands: date uname hostname
* Command for modifying Command Behavior: chroot env nice nohup su
* Process control command: kill
* Latency command: sleep
* Numeric Operation Command: factor seq

4. Self-learning every command
If you have installed a better desktop version, such as Ubuntu, you can click in the following order to view the information of all commands.


Whether or not you have time to read the help information of all commands. You must read several short texts in the "Common options" column on the left. This is common to most Linux commands. For example, if you add -- help to any command, the help information of the command is displayed.
For example, the long option format and short option format of the command, and the Command Option Terminator.

If you want to operate a file with the file name "-h", can you try to delete the file with the file name "-h? After reading this "Common options", you will know.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.