01. Introduction to Linux

Source: Internet
Author: User
Tags bz2 clear screen control characters file permissions

I. INTRODUCTION of Linux

Linux is a free-to-use and free-to-propagate Unix-like operating system, a POSIX and Unix-based multiuser, multitasking, multi-threaded and multi-CPU operating system. It can run major UNIX tools software, applications, and network protocols. It supports 32-bit and 64-bit hardware. Linux inherits the design idea of Unix as the core of network, and is a stable multi-user network operating system.

The Linux operating system was born on October 5, 1991 (This is the first time the official outward announcement). There are many different Linux versions of Linux, but they all use the Linux kernel. Linux can be installed in a variety of computer hardware devices, such as mobile phones, tablets, routers, video game consoles, desktops, mainframes, and supercomputers.

Strictly speaking, the word Linux itself only represents the Linux kernel, but in fact people have become accustomed to using Linux to describe the entire Linux kernel, and use the GNU engineering various tools and databases of the operating system.

Second, the main characteristics Basic Ideas

The basic idea of Linux has two points: first, everything is a document; second, each software has a definite purpose. The first article in detail is that everything in the system boils down to a file, including commands, hardware and software devices, operating systems, processes, and so on for the operating system kernel, all of which are considered to have their own attributes or types of files. Linux is Unix-based, largely because of the similarity between the two basic ideas. [3]

completely free

Linux is a free operating system that can be obtained free of charge through the Internet or other channels, and can be arbitrarily modified by the source code. This is not what other operating systems can do. Because of this, countless programmers from all over the world are involved in the modification and writing of Linux, and programmers can change them according to their own interests and inspirations, which allows Linux to absorb the essence of countless programmers and grow. [4]

Fully compatible with the POSIX1.0 standard

This makes it possible to run common DOS and Windows programs under Linux with the appropriate simulator. This lays the groundwork for users to go from Windows to Linux. When many users consider using Linux, they think about whether the programs that were common to windows before are working properly, which eliminates their doubts. [4]

Multi-user, multi-tasking

Linux supports multiple users, each user has their own special rights to the file device, to ensure that the user does not affect each other. Multitasking is one of the most important features of computers now, and Linux allows multiple programs to run simultaneously and independently. [4]

a good interface

Linux has both a character interface and a graphical interface. In the character interface, the user can use the keyboard to enter the appropriate instructions. It also provides a x-window system similar to the Windows graphical interface that allows users to manipulate it using the mouse. In the X-window environment, like in Windows, it can be said to be a Linux version of Windows. [4]

supports multiple platforms

Linux can run on a variety of hardware platforms, such as those with x86, 680x0, SPARC, and Alpha processors. In addition, Linux is an embedded operating system that can run on a handheld, set-top box, or game console. The Linux version 2.4 kernel, released in January 2001, has been able to fully support the INTEL64 bit chip architecture. Linux also supports multi-processor technology. Multiple processors work at the same time, which greatly improves system performance. [4]

III. Structure of the document

/: root directory, all directories, files, devices are in/below,/is the Linux file system Organizer, is also the most superior leader.

/bin:bin is the binary (binary) abbreviation. In the general system, you can find the common Linux commands in this directory. The commands required by the system are located in this directory.

/boot: The Linux kernel and the file directories required for the boot system program, such as the Vmlinuz initrd.img files, are located in this directory. In general, the GRUB or LILO system Boot Manager is also located in this directory.

/cdrom: This directory is empty when the system is just installed. You can attach the optical drive file system to this directory. Example: Mount/dev/cdrom/cdrom

/ Dev:Dev is an acronym for devices. This directory is important to all users. Because this directory contains all the external devices used in the Linux system. But this is not the driver for the external device. This is not the same as the common Windows,dos operating system. It is actually a port that accesses these external devices. It is very easy to access these external devices, and to access a file, a directory without any distinction.

/etc:etc This directory is one of the most important directories in the Linux system. This directory contains the various configuration files and subdirectories to be used in system administration. To use the network configuration files, file system, x system configuration files, device configuration information, set up user information, etc. are in this directory.

/home: If a user is created, the user name is "xx", then there is a corresponding/home/xx path in the/home directory, which is used to store the user's main directory.

/lib:Lib is the English abbreviation of library. This directory is used to store the system dynamic connection shared library. Almost all applications use shared libraries in this directory. Therefore, do not easily do anything to this directory, once the problem occurs, the system will not work.

/lost+found: in the ext2 or ext3 file system, when the system crashes unexpectedly or the machine shuts down unexpectedly, some file fragments are placed here. When the system starts, the Fsck tool checks here and repairs the corrupted file system. Sometimes problems with the system, a lot of files are moved to this directory, may be repaired in a manual way, or moved to the original location of the file.

/mnt: This directory is generally used to store mounted storage devices, such as CDROM directory. You can see the definition of/etc/fstab.

/media: Some Linux distributions use this directory to mount the USB interface's removable hard drives (including USB sticks), CD/DVD drives, and so on.

/OPT: This is where the optional programs are mainly stored.

/proc: System Information can be obtained in this directory. This information is in memory and generated by the system itself.

/root: Home directory for Linux super User root.

/sbin: This directory is used to store system administrator's system management program. Most of the commands involved in system Management, is the super-user root executable command storage, ordinary users do not have permission to execute this directory commands, this directory and/usr/sbin; The/usr/x11r6/sbin or/usr/local/sbin directory is similar, and the directory sbin contains root permissions to execute.

/selinux : For some of SELinux's profile directories, SELinux can make Linux more secure.

After the /srv service is started, the data directory to be accessed, for example, the Web page data that the WWW service starts to read can be placed in a/srv/www

/tmp: temporary file directory, which is used to store temporary files generated when different programs are executed. Sometimes when a user runs a program, a temporary file is generated. /tmp is used to store temporary files. The/var/tmp directory is similar to this directory.

/usr

This is the largest directory in the Linux system that occupies hard disk space. Many of the users ' applications and files are stored in this directory. In this directory, you can find additional tools that are not suitable for use in/bin or/etc directories.

/usr/local: The main store is the software that is installed manually, that is, not through "new" or Apt-get installed. It has a similar directory structure to the/usr directory. Let the package Manager manage the/usr directory and put the custom script (scripts) under the/usr/local directory.

/usr/share: things that the system uses to store, such as/usr/share/fonts are font directories,/usr/share/doc and/usr/share/man Help files.

/var: The contents of this directory are constantly changing, see the name to know, can be understood as vary abbreviation,/var under/var/log This is used to store the system log directory. The/var/www directory is the directory where the Apache server site is defined, and/var/lib is used to store some library files, such as MySQL, and the location of the MySQL database.

Iv. Common Commands

One. General Command: [6]

Date:print or set the system date and time

2. Stty-a: can view or print control characters (ctrl-c, ctrl-d, ctrl-z, etc.)

3. Passwd:print or set the system date and time (viewed with passwd-h)

4. Logout, Login: Login and logoff command for logon shell

5. Pwd:print working Directory

6. More, less, head tail: Displays or partially displays the contents of the file.

7. Lp/lpstat/cancel, LPR/LPQ/LPRM: Print the file.

8. Change file permissions: chmod u+x ...

9. Delete a non-empty directory: Rm-fr dir

10. Copy directory: Cp-r dir

FG Jobid: A background process can be placed in the foreground.

Ctrl-z can suspend the foreground process (suspend) and then use BG Jobid to run it in the background.

Job & can directly run the job directly in the background.

The role of Kill: Send a signal to a process. Eg:kill-9 is sending the Sig_kill signal ... What signal is sent can be viewed through man kill.

Usage of PS, ps-e or Ps-o pid,ppid,session,tpgid, Comm (where session shows the SessionID, Tpgid shows the foreground process group ID, Comm displays the command name. )

Two. Ubuntu Common commands: [6]

1. Dpkg:package Manager for Debian

* Installation: Dpkg-i Package

* Uninstall: Dpkg-r Package

* Uninstall and delete profile: Dpkg-p |--purge Package

* If a package is installed. Said to rely on some libraries. You can first Apt-get install somelib ...

* View Package installation content:d Pkg-l packages

* See which package is available for the file: dpkg-s filename

* There are also dselect and aptitude two frontend in addition to the dpkg.

2. Apt

* Installation: Apt-get Install packs

* Apt-get Update: Updating source

* Apt-get Upgrade: Upgrade the system.

* Apt-get dist-upgrade: Smart upgrade. Install new packages, remove obsolete packages

* Apt-get-f Install:-F = =--fix Broken Repair Dependency

* Apt-get autoremove: Automatic removal of useless software

* Apt-get Remove Packages: Remove software

* Apt-get Remove Package--purge Remove packages and clear configuration files

* Remove the residual profile for the package: dpkg-l |grep ^rc|awk ' {print $} ' |tr ["/n"] [""]|sudo Xargs dpkg-p

* Temporary storage directory for packages when installing software:/var/cache/apt/archives

* Clear this directory: Apt-get clean

* Clear the old version of the software cache for this directory: Apt-get AutoClean

* Query software some dependency package: Apt-cache depends some

* Query software some by which package depends on: Apt-get rdepends some

* Search Software: Apt-cache search Name|regexp

* Check the role of the package: Apt-cache Show Packages

* View a compilation dependency library for a software: Apt-cache showsrc packagename|grep build-depends

* Source code of the downloaded software: apt-get source PackageName (Note: There should be deb-src source in sources.list)

* Install the package source code at the same time, install its compilation environment: Apt-get BUILD-DEP PackageName (with DEB-SRC source)

* How to add a local CD to the installation Source list: Apt-cdrom add

3. System command:

* View Kernel version: Uname-a

* View Ubuntu version: Cat/etc/issue

* Check NIC status: Ethtool eth0

* View memory, CPU information: cat/proc/meminfo; Cat/proc/cpuinfo

(There are a lot of system information/proc below)

* Print File system space usage: df-h

* View hard disk partition: Fdisk-l

* Production look file size: du-h filename;

* View Directory Size: Du-hs dirname; Du-h DirName is to view the size of all files in the directory

* View Memory Usage: free-m|-g|-k

* View process: PS-E or Ps-aux--show Users

* Kill the process: Kill PID

* Forced Kill: killall-9 ProcessName

4. Network-Related:

* Configuration Adsl:sudo pppoeconf

* ADSL manual dialing: sudo pon dsl-provider

* Activate Adsl:sudo/etc/ppp/pppoe_on_boot

* Disconnect Adsl:sudo Poff

* According to IP check NIC address: arping IP Address

* Production to see local network information (including IP, etc.): ifconfig | Ifconfig eth0

* View routing information: Netstat-r

* Switch off the NIC: sudo ifconfig eth0 down

* Enable NIC: sudo ifconfig eth0 up

* Add a service: sudo update-rc.d service name defaults 99

* Delete a service: sudo update-rc.d service name remove

* Temporarily restart a service:/etc/init.d/Service Name restart

* Temporarily shut down a service:/etc/init.d/service name stop

* Temporarily start a service:/etc/init.d/service name start

* Under Console display Chinese: sudo apt-get install Zhcon

* Find a file: Whereis filename or find directory-name file name

* Transfer files via SSH

scp-rp/path/filename [Email Protected]:/path #将本地文件拷贝到服务器上

SCP-RP [Email Protected]:/path/filename/path #将远程文件从服务器下载到本地

5. Compression:

* Unzip A.tar.gz:tar ZXVF a.tar.gz

* Unzip A.tar.bz2:tar JXVF a.tar.bz2

* Compression AAA BBB Catalog for Xxx.tar.gz:tar ZCVF xxx.tar.gz AAA BBB

* Compression AAA BBB directory for Xxx.tar.bz2:tar JCVF xxx.tar.bz2 AAA bbb[6]

6. Nautilus:

Special URI Address

* computer:///-all mounted devices and networks

* network:///-Browse available networks

* burn:///-a data virtual directory for burning Cds/dvds

* smb:///-Available Windows/samba network resources

* x-nautilus-desktop:///-Desktop items and icons

* file:///-Local file

* trash:///-Local Recycle Bin directory

* ftp://-FTP Folder

* ssh://-SSH folder

* fonts:///-font folder, you can drag the font file here to complete the installation

* themes:///-System Theme Folder

* Show hidden files: ctrl+h

* Show Address bar: Ctrl+l

* View installed Fonts: Enter "fonts:///" in Nautilus's address bar to view all fonts[6 in this machine]

7. Supplementary sections:

* View all local TPC,UDP listening ports: NETSTAT-TUPLN (T=tcp, U=UDP, P=program, L=listen, N=numric)

* Through man search said the relevant command: MAN-K keyword. Eg:man-k User

* or with Apropos

* Actual disk space occupied by the statistics file: Du (du-estimate file space usage)

* Statistics file characters, Bytes: wc-c/-l/-w (wc-print the number of newlines, words, and bytes in files)

* View the contents of the file: od-x/-c/.... (od-dump files in octal and other formats)

I think the most useful od is the file byte stream: od-t x1 filename

View the Ascii form of the file: od-t C filename (where the leftmost statistic is: bytes)

* Locate the file where the command is located: which OD output:/usr/bin/od

See which package the file is provided with: dpkg-s/usr/bin/od output: coreutils:/usr/bin/od

Check out the full contents of the Coreutils package and know the Core Linux command: Dpkg-l coreutils

Then info coreutils haha, seriously learn it, the all over the command!

* The explanation of all sections of a command can be produced with the man command: Man-a TTY

Then use Q, and next to translate the explanation to the next section

* Bash's handy shortcuts:

CTRL + A: The cursor moves to the beginning of the line.

CTRL+B: The cursor moves left one letter

CTRL + C: kills the current process.

Ctrl+d: Exits the current Shell.

Ctrl+e: The cursor moves to the end of the line.

Ctrl+h: Deletes the previous character of the cursor, same as the BACKSPACE key.

Ctrl+k: Clears the contents of the cursor to the end of the line.

Ctrl+l: Clear screen, equivalent to clear.

Ctrl+r: Search for previously played commands. There will be a hint to search for the history of bash based on the keywords you entered

Ctrl+u: Clears all content before the cursor to the beginning of the line.

Ctrl+w: Remove a word before the cursor

Ctrl+t: Swap two characters before the cursor position

Ctrl+y: Paste or restore the last delete

Ctrl+d: Delete the letter of the cursor, note the difference between backspace and ctrl+h, and these 2 are the characters before the cursor is deleted.

CTRL+F: Cursor Right Shift

CTRL + Z: Move the current process to the background and use the ' FG ' command to recover. Like top-d1 then CTRL + Z, into the background, then FG, re-restore

* Quick paste: First select the text in one place, click the middle mouse button in the place where you want to paste.

* Equivalent Middle key: A, press the pulley equivalent to the middle button. b, at the same time press the mouse key, equivalent to the middle button.

* Fast Restart X service: Press: Alt + Ctrl + Backspace three keys.

* Open the Run window: Press the ALT + F2 key at the same time.

* Screenshot: A, Full screen: Press the PRTSCR button directly.

B, Current window: Press ALT + PRTSCR key at the same time.

C, Time-lapse screenshot: Enter the command in the terminal or "Run" window: Gnome-screenshot--delay 3, will delay 3 seconds after the screenshot.

* Simply drag files from the File Manager to the GNOME terminal to get the full pathname in the terminal. [6] 8.ulimit

Ulimit: Displays (or sets) the limits of the resources that the user can use, which are limited to soft limits (current limit) and hard limits (caps), where the hard limit is the upper limit of the soft limit, and the system resources used by the application do not exceed the corresponding soft limit in the run process. Any transcendence leads to the termination of the process.

Ulimited does not restrict the resources that users can use, but this setting sets the maximum number of files that can be opened (max Open file)

And the maximum number of processes that can run concurrently (max user processes) is invalid

-A lists all current resource limits

-C Sets the maximum value of the core file. Unit: Blocks

-D sets the maximum value of the data segment for a process. Unit: Kbytes

-F Shell The maximum file size of the created file, in: Blocks

-h Specifies to set the hard limit for a given resource. If the user has root user rights, the hard limit can be increased. Any user can reduce the hard limit

Maximum number of physical memory that can be locked by-l

The maximum number of resident memory that can be used by-M, in: Kbytes

-N Maximum number of files per process that can be opened at the same time

-P Sets the maximum value of the pipe in block,1block=512bytes

-s Specifies the maximum value of the stack: unit: Kbytes

-s specifies to set the soft limit for a given resource. The soft limit can be increased to the value of the hard limit. If the-H and-s flag are not specified, the limit applies to both

-t specifies the number of seconds to use per process, in units: seconds

The maximum number of concurrent processes that can be run by-u

The maximum amount of virtual memory that the-V shell can use, in units: Kbytes

EG:ULIMIT-C 1000 (You can see the original value by Ulimit-c first)

01. Introduction to Linux

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.