Linux Operating System Learning notes

Source: Internet
Author: User
Tags create directory file copy parent directory readable

For a detailed introduction to Linux, see: http://blog.csdn.net/hguisu/article/details/6122513

1, installation of Linux operating system

Currently basically is based on the Windows operating system installed on the installation of Windows on the virtual machine installed on the installation of Linux system, mainly CentOS (Enterprise Services with this more) and Unbantu (personal notebook installation with this more) two use more.

2. System structure

    • Kernel is the core of the operating system, has many basic functions, it is responsible for managing the system's processes, memory, device drivers, files and network systems, determine the performance and stability of the system. The Linux kernel consists of the following components: memory management, process management, device drivers, file systems, and network management.

    • The shell is the user interface of the system and provides an interface for users to interoperate with the kernel. It receives the command entered by the user and sends it to the kernel to execute, which is a command interpreter. In addition, Shell programming languages have many features of common programming languages, and Shell programs written in this programming language have the same effect as other applications.
      Currently, the following versions of the shell are mainly available.
      1. Bourne Shell: It was developed by Bell Labs.
      2. BASH: Is the GNU Bourne Again Shell, which is the default shell on the GNU operating system, and most Linux distribution kits use this shell.
      3. Korn Shell: The development of the Bourne Shell, which is compatible with the Bourne shell in most of the content.
      4. C Shell: Is the BSD version of Sun's shell.

    • Application
3. File system

Linux file system and Ms-windows file system is very different, for the Microsoft Windows system file structure I don't say much here, we mainly end the Linux file system structure. Linux has only one file tree, the entire file system is a root "/" as the starting point, all the files and external devices are in the form of files hanging in this file tree, including hard disks, floppy disks, optical drives, modems, and so on, and to " The drive letter-based ms-windows system is very different. The file structure of Linux embodies the simplicity of this operating system, and the root of the Linux distributions that we are exposed to is mostly the following structure:

/bin/sbin/etc/lost+found/var/boot/root/home/mnt/tmp/dev/lib/proc/usr

Now I'll give you a brief introduction to these catalogs:

    • 1. /bin and /sbin: Most of the basic procedures for using and maintaining UNIX and Linux systems are contained in/bin and/sbin , The fame of these two directories includes the bin because the executable program is binary (binary files ).

The/bin directory is typically used to store the user's most commonly used basic programs, such as:

Login

Shells

File Operations Utility

System Utilities

Compression tools

The/sbin directory typically holds basic system and system maintenance programs, such as:

Fsck fdisk MKFS shutdown LILO Init

The main difference between the programs stored in these two directories is thatthe programs in/sbin can only be performed by root (Administrator) .

    • 2. /etc: This directory is typically used to store the entire file system configuration file required by the program

Some of these important documents are as follows:

passwd Shadow Fstab hosts MOTD profile shells Services lilo.conf

    • 3. /lost+found: This directory is specifically used for those who restart the system after the system is not normal, do not know where to restore the "stray" file.
    • 4. / Boot: This directory contains various files that are related to system startup, including the system's boot program and the core of the system.
    • 5. /root: This is the home directory of the system administrator (root).
    • 6. / home: All of the users in the system are hosted in/house, which contains the home directory of the actual user (person) and the other user's home directory.
    • 7. The/MNT:/MNT directory typically contains subdirectories, each of which is an installation point for a particular device type.

As agreed, movable media such as CD-ROM, floppy disk, zip disk, or Jaz should be installed in the/MNT directory, for example:

/cdrom/floppy/zip/win ....

If we want to use these specific devices, we need to use the Mount command to hang the external device from the/dev directory. Here you may see there is a win directory, this is my machine above a window to the Windows file system to the point of contact, so I access this directory can access my Windows under the file. But if your Windows file system is in NTFS format, this is not the way to go.

    • 8. / tmp and/ var: these two directories are used to store temporary files and frequently changing files.
    • 9. /dev: This is a very important directory, it holds a variety of external device image files, some of which we have to firmly remember. For example, the first floppy disk drive name is FD0, the first hard disk name is HDA, the first partition on the hard disk is hda1, the second partition is hda2; the first optical drive is the HDC; In addition, the name of the modem and other peripherals, in so many names, All we need to do is remember the most commonly used peripherals.
    • /usr: By convention, this directory is used to store programs or files that are directly related to the user of the system, which has a home directory for each system user, which is relative to their small "/".
    • /proc: This directory below is a virtual image of the process currently running on the system, where we can see some directories consisting of the currently running process numbers, and a kernel file that records the current contents of the memory.
5. Common commands:Command + parameter item + action file
    • ifcofig NIC name IP address//configure network
    • telnet host name/IP port number//Telnet
    • ls : This command is equivalent to the dir command under DOS, which is one of the most important commands in the Linux console command. LS The most commonly used parameters are three: -a-l-F.
      • ls-a: Files on Linux are treated as hidden files by the system, and only the LS command is not visible to them, and the hidden files are displayed with Ls-a in addition to the generic filenames .
      • ls-l(This parameter is the lowercase letter L, not the number 1): This command can use the long format to display the contents of the file, if you need to see more detailed file information, it is necessary to use the Ls-l this command . For example, if I type ls-l in a directory, the following information may be displayed (the top two lines are my own):

Position 1 2 3 4 5 6 7

Number of file properties files The group file size file name to which the owner belongs

drwx------ 2 Guest users 1024x768 21:05 Mail

-rwx--x--x 1 root root 89080 Nov 7 22:41 tar*

-rwxr-xr-x 1 Root bin 5013 9:32 uname*

lrwxrwxrwx 1 root root 4 Nov 19:30 zcat->gzip

-rwxr-xr-x 1 Root bin 308364 Nov 7:43 zsh*

-rwsr-x---1 root bin 9853 5:46 su*


Now, let me explain what these displays mean.

The first field that represents the properties of the file.

Linux files are basically divided into three properties: readable (R), writable (W), executable (x). But here are 10 squares to add (when the actual program is implemented, it is actually 10 bit bits).

            • The first small is a special representation, indicating a directory or a link file, and so on, d means a directory, such as drwx------; L represents a Nexus file, such as lrwxrwxrwx, or a horizontal "-" indicating that this is a file.
            • The 2nd to 4th small represents the current user's permissions, r--readable, w--writable, x--executable
            • The 5th to 7th small represents the permissions of the current user's group, r--readable, w--writable, x--executable
            • The 8th to 10th small represents the permissions of other users, r--readable, w--writable, x--executable
        • ls-f(note, uppercase F): Using this parameter means adding more symbols for the file type after the file, such as * for the executable,/for the directory, @ for the Nexus file, because the-f parameter is used. But now basically all Linux distributions of LS have built-in the-f parameter, that is, we can see a variety of resolution symbols without entering this parameter.

1. Display all file and directory information for the current directory
> ls//list
> ls xx directory//view file information below the specified directory

2. Display the current file directory location
> pwd

3. Switch between directories
> CD Catalog Name
> CD. Switch to Parent directory

4. Switch to full command mode
> init 3 into Command mode
> init 5 into Visual interface

5. User switches to Super admin
> Su-root//$ is a regular user #是超级管理员
> Su-
> su root//can also switch to root user, but no Super Administrator privileges

6. Super Admin switch back to normal user
> Exit

7. See who the current user is
> WhoAmI

8. Output a file content
> Cat Specific files

9. Create directory make Directory
> mkdir Hello
> mkdir Hello/world
> mkdir-p first/second/third//Recursive creation of 3 directories

10. Change the name of the catalog move move
> MV old name New name
> MV Book.ods bread.ods
> MV First/second first/six//Change the name of second to six

11. Move Directory Operation move
> MV Target new address
> MV Bread.ods Catalogue
> MV Ten/bread.ods First//mobile because the first directory exists
MV Ten/bread.ods FIRSTT//Change the name and move the file to the current directory

MV Destination address//move, as long as the address is present directory is mobile
MV Target address//change name, address as long as it does not exist or change the name

12. Copy-operation copy
> CP source file Copy file
> cp-r Directory target directory//copy "directory" need to add parameter-R
> CP source file target/new name//copy and give a new name at the same time

13. Delete directories, files
> RM File//Delete individual files
> rmdir directory//delete a single directory
> RM-RF file//can delete all normal directories or files recursive recursive force
RM-RF///Kill your Self

14. Output File Contents
> Cat file//One-time output file full contents
> more File//pagination display file contents
Hit Enter to view the contents below, do not support back to see
Middle STOP: Q
Display content Percentage
> Less File//page display of file contents
You can view the contents of the file by up, down, left and right.
STOP: Q
No percent display
> head-n File//view the first n rows of a file
> tail-n File//View the end of the file n lines of content

15. Calculate the number of file lines
> WC file//Calculate the number of file lines

16. Create a file
> Touch filename//Create a file

17. Add content to a file
> Echo content > FileName//Add content to file [overwrite add content, original content is deleted]
> Echo content >> filename//Add content to a file
> Echo Content >/>> newfilename//Creates a new file with add content [redirect mode]


18. Add a user to the system
User Add/mod/del
> Useradd username//Add a user
The user is created by the way, and the set user's group is not displayed
> useradd-g NNN username//Add user and set group
> useradd-g nnn-d Directory user name//add user and set home directory, group
> useradd-u XXX username//Add user and display set user number

18.1 Modifying users
> Usermod-u User number-G group number-D home directory user name//modify User

18.2 Deleting a user
> Userdel-r user/delete user, and delete home directory


19. Create a group for the system
Group Add/mod/del
Groupadd Movie
Groupadd Music
Groupadd-g XXX Group name//Add group and set group number

19.1 Modifying a group
> groupmod-n new name Old name//modify the name of the group
19.2 Deleting a group
> Groupdel Group Name


20. View System User Information
> CAT/ETC/PASSWD User Information
> Cat/etc/group Group Information

21. View specific instructions using the parameter method
> Man command

22. Set a password for the user
> passwd User Name

Linux Operating System Learning notes

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.