Getting started with C Programming in Unix/Linux (39) shell Command System Management, getting started with shell

Source: Internet
Author: User

Getting started with C Programming in Unix/Linux (39) shell Command System Management, getting started with shell
Df command

  • This function is used to detect disk space usage and free space in a file system. It displays the usage of nodes and disk blocks in all file systems. The command format is as follows:

    Df [Option]

    Common Parameters and meanings are shown in the following table.

    Df-a: displays the disk usage of all file systems, including 0 block file systems.

    Df-h: output file system size in an understandable format, such as 345 kb, MB, and 46 GB.

    Df-I: displays the I node information, not the disk block.

    Df-t: displays the disk space usage of each specified type of file system.

    Df-x: List disk space usage of a file system of a specified type.

    Df-T: displays the file system type.

    The unit of df is 512 bytes.

    The unit of df-k is 1024 bytes.

  • Du (show disk usage) to view disk usage

    Syntax

1

2

Du [-abcDhHklmsSx] [-L <symbol connection>] [-X <File>] [-- block-size]

[-- Exclude = <directory or File>] [-- max-depth = <directory layers>] [-- help] [-- version] [directory or file]

Common Parameters

-A or-all shows the disk usage for each specified file, or shows the disk usage for each file in the directory.

-B or-bytes: displays the size of directories or files in bytes.

-C or-total not only displays the directory or file size, but also the total number of all directories or files.

-D or-dereference-args displays the size of the source file connected by the specified symbol.

The unit of-h or-human-readable is K, M, and G, which improves information readability.

The-H or-si parameters are the same as the-h parameters, but K, M, and G are in units of 1000, rather than 1024.

-K or-kilobytes is in the unit of 1024 bytes.

-L or-count-links repeat the hardware connection file.

-L <symbol connection> or-dereference <symbol connection> shows the size of the source file for the specified symbol connection.

-M or-megabytes is in the unit of 1 MB.

-S or-summarize only displays the total, that is, the size of the current directory.

-S or-separate-dirs displays the size of each directory in hours without the size of its subdirectories.

-X or-one-file-xystem is based on the file system at the beginning of processing. If it encounters a different file system directory, it is skipped.

-X <File> or-exclude-from = <File> specifies the directory or file in <File>.

-Exclude = <directory or File> skips the specified directory or file.

-Max-depth = <directory layers> if the number of directories exceeds the specified number of directories, ignore the directory.

-Help: displays help.

-Version: displays the version information.

 

  • Mkfs command

    This command is equivalent to the formatting command in DOS/Windows systems, used to create a specified file system. The format is as follows:

    Mkfs [Option] device file name [blocks]

    Common Parameters and meanings are shown in Table 3-6.

    This command is generally not suitable unless you know its usage.

  • Use rpm tool to install Application Software

    Linux provides the RedHat package management tool rpm (RedHatPackage Manager) to manage the installation and uninstallation of applications.

    It is a software package and release program that implements automatic installation. The software package needs to be installed with the rpm program. Its suffix is. rpm and can be installed, unloaded, and maintained on this package. The rpm command format is as follows:

    Rpm [Option] [package name]

    Uninstall the software.

    Rpm-ivh software name non-installation package name

     

    Check whether the software has been installed?

    Rpm-qa | grep software name

     

  • Su-command switch user

    Usage

    Su [user name]

    To return the original normal user account, enter the exit command directly.

    If you want to enter another common user account, you can add another account directly after the su command, and then enter the password.

    If the su command does not contain the user name, the system switches from the current user to the super user by default, and prompts the user to enter the Super User Password.

    The difference between the su and su-commands is that when su-switches to the corresponding user, the current working directory is automatically converted to the user's home directory after the switch.

  • Add User Account

    You can use the adduser or useradd command to add a user account in Linux. Because the adduser command is a link to the useradd command, the two commands are in the same format.

    The format of the useradd command is as follows:

    Useradd [parameter] create a user account

    Common Parameters and meanings are shown in the following table.

  • Passwd-set the User Password

    In Linux, superusers can use the passwd command to set or modify user passwords for common users. You can also directly use this command to modify your own password without using the user name after the command. The common format of this command is:

    Passwd [parameter] User Name

  • Userdel-delete a user

    The command format is as follows:

    Userdel [-r] [user name]

    If the-r parameter is used, the user's home directory is deleted while deleting the user.


Use the Shell commands in Unix/Linux to perform the following operations on your computer:

#! /Bin/bash

Ls-l
Mkdir mydir
Cd mydir
Pwd
Touch myshell
Chmod + x myshell
Cat myshell
Cp myshell ..
Rm-f myshell
Mv ../myshell.

-----------------------------------

~ /Work/shell/test $ cat xx. sh
#! /Bin/bash

Ls-l
Mkdir mydir
Cd mydir
Pwd
Touch myshell
Chmod + x myshell
Cat myshell
Cp myshell ..
Rm-f myshell
Mv ../myshell.

~ /Work/shell/test $./xx. sh
Total 4
-Rwxr-xr-x 1 oliver 131 xx. sh
/Home/oliver/work/shell/test/mydir
~ /Work/shell/test $ ls-ltr mydir
Total 0
-Rwxrwxr-x 1 oliver 0 2012-12-17 :22 myshell
~ /Work/shell/test $

Unix operating system and Shell tutorial

Correspond to your two requirements respectively:
1. Linux system analysis and Advanced Programming Technology
This book introduces the programming methods in Linux, including Linux system commands, Shell scripts, programming languages (gawk, Perl), system kernel, security systems, X Windows, etc, rich in content and comprehensive discussion, covering all aspects of the Linux system. See the third and fourth sections.

Article 3 Linux Kernel Analysis
Chapter 2 Introduction to Linux Kernel
Chapter 4 System Processes
Chapter 4 Memory Management
Chapter 4 inter-process communication
Chapter 2 PCI
Chapter 4 interrupt and interrupt handling
Chapter 4 Device Drivers
Chapter 4 File System
Chapter 2 Network System
Chapter 4 System Kernel Mechanism

Article 4 Linux Advanced Programming
Chapter 2 Linux kernel module programming
Chapter 2 programming of Process Communication
Chapter 2 advanced Thread Programming
Chapter 2 network programming for Linux
Chapter 2 Linux I/O port programming

2. laruence's Linux Private food Basics
Of course, it is not enough to have a better understanding of sed and awk. This book only describes the basics.
Grep usage is basically enough.

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.