Basic Linux knowledge 99 (5)

Source: Internet
Author: User

5. Do a good job as a Linux administrator: 21

70. How can I check Linux hard disk usage?

In Linux, you can use the df command to view the hard disk usage. The following is an input example of a df-T-h (-T parameter: displays the file system type, and the-h Parameter displays information in a readable way) command:

Filesystem Type Size Used Avail Use % Mountedon

/Dev/hda1 ext2 7.5G 4.7G 2.5G 65%/

/Dev/hda2 ext2 653 M 6.6 M 613 M 1%/root

/Dev/hdb1 ext2 7.5G 3.5G 3.7G 49%/usr

71. What compression tools are available in Linux?

There are many compression tools in Linux, commonly used:

1) gzip/gunzip: this is a free software developed by GNU and widely used. The compressed file extension is ". gz ". The usage is simple, for example:

Gunzip eos.gz gzip/home/test/*. txt;

2) compress/uncompress: This is a pair of historical compression programs. After a file is compressed, the compressed file extension is ". Z ".

3) In addition, there are zip/unzip, bzip2/bunzip2, and so on.

72. How to manage processes?

A process is an execution of a program. You can use "ps-auxw" to list the details of the processes currently being executed, including the ID of each process. You can terminate a process by using the "kill process ID.

73. What does object or directory permission mean?

The file or directory permission bit consists of 10 digits, such as-rwxr-xr-x.

1) first represents the file/directory type: d represents the directory,-represents the file, and l represents the link;

2) the remaining 9 characters are divided into three groups, each with three characters. The 2-4 characters describe the permissions of the file owner. The 5-7 characters describe the permissions of the same user group as the file owner, 8-10 digits are the permissions of other users.

3) rwx: The three digits in each group are: Read Permission, write permission, and execution permission. If yes, the group does not have this permission.

-Rwxr-xr-x indicates that this is a common file. The file owner can read, write, and execute this file, users in the same group as the file owner and other users can read and execute the file.

74. What is a user account?

In Linux, a user account is used to identify each user. During logon, you can enter a different user account and password to determine your identity. In other words, Linux uses user accounts and all users of the management system.

Then you can create some user groups, add users to the groups, and grant them the permissions of the user groups.

75. in Linux, how do I manage users?

If you want to add a new user:

1) Log On As root and run "adduser user account name"

2) Execute "passwd User Account Name" to set a password for this user account.

Run "userdel User Account" to delete a user;

Execute "groupadd user group name" to add a user group;

Run "groupdel user group name" to delete a user group;

76. How do I set a disk quota for users?

1) modify the/etc/fstab file in the following format for the partition where the disk quota is to be set:

/Dev/hda2/home ext2 defaults, usrquota 1 2

2) create an empty file named quota. user in the partition directory where you want to set the disk quota

# Touch/home/quota. user

# Chmod 600/home/quota. user

3) after the system is restarted, you can use the edquota-u user name to set it.

77. How do I back up the system?

In Linux, you can use the dump/restore Command Group to back up and restore the system. Assume that you need to completely back up all files in the/usr directory to the tape drive (assuming the device is rmt8, different tape drives are different), you can run the following command:

Dump-O-f/dev/rmt8/usr

The-O parameter indicates that all files are backed up. The "-f Device File Name" parameter specifies the backup location and the last directory name specifies the content to be backed up.

Then, you can use the following command to restore:

Restore-r-f/dev/rmt8

78.how to install the .tar software package?

Linux software can be released in two ways: source code and executable file packages. The archive file first uses the tardocuments, and then uses the gzipcompressed file to generate the file ended with .tar.gz.

You can decompress the package directly using "tar xvfz file name.

If you get an executable package, the installation is complete.

If you get the source code package, you need to compile it again:

1) Run "./configure" in the extract directory for configuration;

2) Run "make" in the decompressed directory to compile;

3) Run "make install" to install the SDK.

79. How to Use RPM to install Linux software?

The RPM tool provided by RedHat makes it easier to install Linux software.

1) installation: rpm-ivh somesoft. rpm

2) reverse installation: rpm-e somesoft. rpm

3) query: rpm-q somesoft

80. What should I do if I forget the root password?

If you forget the root password, use the following methods to restore it:

1) Restart Linux. When lilo is displayed: Enter linuxsingle to enter the single user mode;

2) The root permission is obtained without a password;

3) Run passwd to reset the root password.

81. What should I do when I reinstall Windows and destroy Lilo?

In this case, you can use two methods to restore:

1) Start the disk in Linux, execute/sbin/lilo, and create lilo again in the boot area;

2) use the Linux installation CD to start and select upgrade system. lilo will be rebuilt.

82. How to Create a Linux boot disk?

In Linux, there is a mkbootdisk tool that can easily create a system boot disk:

1) view the system version, which can be viewed through ls/usr/src;

2) Insert an empty floppy disk;

3) Run "mkbootdisk -- verbose 2.2.5 ".

83. How to remotely use Linux?

We can use commands such as telnet, rlogin, rsh, and rcp to remotely use Linux. However, these methods are transmitted in plaintext during transmission, which may lead to many insecure factors. Therefore, try to avoid remotely using the root account to log on to the system.

How to Build Secure Remote logon?

SSH is used for secure remote login, because SSH implements data transmission encryption.

1) The ssh-1.26.tar.gz file is obtained;

2) use tar xvpf ssh-1.26.tar.gz to unlock this package;

3) to the Undo directory/usr/local/src/ssh-1.26 directory to execute./configure;

4) execute make and make install to complete compilation and installation.

5) You can use ssh to establish a secure remote connection with the server installed with SSH.

85. How do I run a scheduled task?

You may be familiar with scheduled tasks in Windows. You can perform scheduled tasks through some simple settings. In the maintenance of Linux, we can also execute some tasks on a regular basis. In this case, we can use:

1) at command: It can read commands on the keyboard or file and then execute the commands at the specified time;

2) crontab waiting process: You can set its configuration file to regularly execute certain tasks.

86. What did Linux do during the boot process?

1) when the host is started, the CPU will give control to the BIOS, And the BIOS will complete the self-check;

2) then the BIOS reads the first sector on the disk and loads the lilo of the Main Boot Sector;

3) lilo selects a different kernel Image Based on the input. If you select linux, it reads the core image under/boot;

4) The core starts hardware detection and device driver initialization, and then runs init

5) The init process runs a series of initialization scripts based on the/etc/inittab configuration;

6) Start the getty process to receive user logon.

87. How do I set the program to run automatically upon startup?

You can add the command you want to execute as soon as you start the system in the following script files:

/Etc/rc. local,/etc/rc. sysinit, and/etc/rc. d/init. d.

88. Why do we need to re-compile the kernel?

In the following cases, you need to re-compile the kernel or add the dynamic kernel module:

1) Update the driver;

2) customize the most reliable kernel based on your needs;

3) Upgrade the Linux kernel.

89. How to re-compile the kernel?

1) Go to the Linux source code Directory: cd/usr/src/linux

2) Execute "make config", "make menuconfig", and "make xconfig" to configure the kernel options, select the desired module, and remove the unwanted module;

3) execute the "make zImage" command. after about 30 to 90 minutes, a new zImage kernel image file will be generated, stored in the/usr/src/linux/arch/i386/boot directory;

4) copy it to the/boot directory;

5) modify the lilo. conf file and add:

Image =/boot/zImage

Label = newlinux

Root =/dev/hda1 (based on the original file)

Run/sbin/lilo to make the modification take effect.

6) Restart. Enter newlinux to start the new kernel during Lilo.

90. What is a dynamic kernel module?

The dynamic kernel module is a successful design of Linux, which makes Linux more flexible and easy to customize. In fact, the dynamic kernel module is a kernel module, which can not re-compile the kernel, dynamically add some functions to the kernel using the "insmod Module name" command, and use the "rmmod Module name" command to remove them from the kernel.

6. Cheap network solution-Linux: 9

91. How to set up a WEB server in Linux?

Apache server is the first choice for setting up WEB servers in Linux. You can choose to install it when installing Linux. If Apache is not installed at the time of installation, you can find the file: apache-1.3.12.i386.rpm from the CD or on the apache website, and then execute the following command to complete the installation:

1) rpm-ivh apache-1.3.12.i386.rpm

2) modify the configuration files httpd. conf and access. conf in the/etc/httpd/conf directory;

3) Put the home page file in the/home/httpd/html directory;

4) Run "/etc/rc. d/init. d/httpd start" to start the Apache server.

If you want to disable it, run the/etc/rc. d/init. d/httpd stop command.

92. How to set up an FTP server in Linux?

In Linux, the most commonly used FTP service software is wu-ftpd, if it is not installed during linux installation. You can obtain the desired rpmpackage from the disc or website rpmfind.net/linux/rpm/wbyname.html:wu-ftpd-2.6.0-9.i386.rpm. Run the following command to complete the installation:

Rpm-ivh wu-ftpd-2.6.0-9.i386.rpm

Edit the "/etc/inetd. conf" file and point to the new ftpd daemon, as shown below:

Ftp stream tcp nowait root/usr/sbin/tcpd in. ftpd-l-

So far, your Linux can accept the FTP service.

93. How to use Linux to set up a E-MAIL server?

In Linux, the most common E-MAIL server is Sendmail, which you can select when installing Linux.

1) make an MX record for the e-mail server on the DNS server;

2) edit the/etc/inetd. conf file and remove the comments about pop and smtp rows;

3) execute kill-HUP inetd to make the modification take effect;

In this way, users on the e-mail server can send and receive emails through clients such as Outlook.

94. How to set up a News server in Linux?

When installing Linux, select the INN package and enable innd when starting the system. During system installation, most of the configuration work has been completed without the need to compile the source code.

1) Configure/etc/news/inn. conf:

Domain: foo.com

Organization: foo company news site

Server: localhost

Fill in according to the actual situation;

2) Configure/etc/news/nnrp. access

Nnrp. access is the configuration file used to complete the nnrpd of the waiting process for the News Readers service. It is used to control access to the site. You do not need to start INND to modify this file.

3) Add a newsgroup:

You can manually edit the/var/lib/news/active file to add a newsgroup, or use the ctlinnd command to add a newsgroup. To manually modify a newsgroup, run the following command to make it take effect:

Ctlinnd reload active "modify active"

95. How to set up BBS in Linux?

1) download the powerbbssource code distribution package file pbbs.tar.gz;

2) execute tar zxvf pbbs.tar.gz to unbind the file;

3) Go To The pbbs directory and run Install;

4) change the default settings as needed.

96. How to make Linux a file server?

In Linux, you can use Samba as the file server. You can select Samba when installing Linux to complete the installation.

1) edit/etc/smb. conf and modify the configuration:

Netbios name = linux

Workgroup = SambaServer

Server string = Samba Server

Hosts allow = 192.168.9. 127.

Securoty = share

Interfaces = 192.168.9.1/24

Name resolve order = host dns bcast

Wins support = no

2) restart the SMB server:/etc/rc. d/init. d/smb restart

3) edit the hosts file of the client and add the parsing to the Samba Server;

4) Finally, you can see it on the network neighbor.

97. How do I set up a proxy server in Linux?

1) download squidproxy server software squid-2.2.stable3-src.tar.gz;

2) execute tar xzxf squid-2.2.STABLE3-src.tar.gz

3) Execute./configure

4) execute make and make install to the/usr/local/squid directory;

5) edit the/usr/local/squid. conf file and add:

Acl allowed_hosts src 192.168.9.0/255.255.255.0

Note: assume that your intranet IP address is 192.168.9.0;

6) execute/usr/local/squid/bin/squid-z for initialization

7) run/usr/local/squid/bin/squid to enable the Service.

8) You can access the Internet by setting the Proxy Server IP address and port 3128 on the client.

98. How to set up a transparent gateway in Linux?

Confirm that the Linux kernel supports ipchain, and then write a script ipchains. rule with the following content:

Note: assume that the Internet address of the transparent gateway server is 1.2.3.4, which is already connected to the Internet; the Intranet address is 192.168.9.1, which is connected to the Intranet.

#! /Bin/sh

/Sbin/ipchains-F forward

/Sbin/ipchains-F input

/Sbin/ipchains-F output

/Sbin/ipchains-P forward DENY

/Sbin/ipchains-P input ACCEPT

/Sbin/ipchains-P output ACCEPT

External_interface = 1.2.3.4

/Sbin/ipchains-A input-j ACCEPT-I lo

/Sbin/ipchains-A output-j ACCEPT-I lo

/Sbin/ipchains-A input-j DENY-I eth1-s 192.168.9.0/24

/Sbin/ipchains-A input-j DENY-I eth1-d 192.168.9.0/24

/Sbin/ipchains-A output-j DENY-I eth1-s 192.168.9.0/24

/Sbin/ipchains-A output-j DENY-I eth1-d 192.168.9.0/24

/Sbin/ipchains-A input-j DENY-I eth1-s $ external_interface/32

/Sbin/ipchains-A input-j DENY-I eth1-s $ external_interface/32

/Sbin/ipchains-A output-j DENY-I eth1-d $ external_interface/32

/Sbin/ipchains-A forward-j ACCEPT-I eth0-s 192.168.9.0/24-d 192.168.9.0/24

/Sbin/modprobe ip_masq_ftp

/Sbin/modprobe ip_masq_quake

/Sbin/modprobe ip_masq_irc

/Sbin/modprobe ip_masq_user

/Sbin/modprobe ip_masq_raudio

/Sbin/ipchains-A forward-j MASQ-I eth1-s 192.168.9.0/24

After running this script, all machines in the 192.168.9.0 network can connect to the Internet by setting the gateway to 192.168.9.1.

99. What server can Linux build?

Linux can also become a Domain Name Server, PPP server, CVS server, router, and firewall, and also build a server cluster system through the LVS solution. Because the length is limited here, it is just a few minutes. If you are interested, you can refer to professional Linux books.

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.