Linux command skills

xiaoxiao2021-03-06  41

1, quickly enter some directory

Type CD or CD ~ Enter the user's Home directory

Type CD - enter the previous entry directory

Type CD / can enter root directory

2, the file color display of the ls command

Add the following to the / etc / profile file!

Alias ​​ls = "ls --color"

The next time you start the BASH, you can display a list of colored directories as in Slackware, where the color has the following:

Blue-> directory

Green -> executable

Red -> Compressed file

Light blue -> link file

Gray-> other files

3, delete useless core files

After the program runs out, sometimes a file called Core, this file is generally large and it is not used, you can delete the release space

4, directly enter X after startup

Edit the / etc / inittab file, change the id: 3: initDefautl to ID: 4: InitDefautl.

However, the search path may have some problems. When you shut down, you have to go directly to / sbin to perform shutdown.

5, forcibly exit X Windows

Sometimes I don't work in X because the program is wrong, I don't have to worry about it, because it is almost like a malignant crane as in Win95, you only need to type the Ctrl Alt Backspace key to return characters. Under the interface.

6, find a file

The Find command adds some parameters to find the file, such as:

#find / usr -name xf86setup -print

Find file XF86Setup in / usr

7, check the files under Win98

Mount / dev / hda1 / mNT is not required to be FAT16.

8, use of floppy drive

If it is Linux's EXT2 file system as the following command:

#mount -t ext2 / dev / fd0 / mnt

The floppy disk in the DOS format uses the command:

#mount -t MSDoS / DEV / FD0 / MNT

Then you can access the content of the floppy disk in / MNT, pay attention to remove the file system on the floppy disk before removing the floppy disk.

#umount / mnt otherwise it will result in loss of information.

The file system is established on the floppy disk can be used as follows:

# MKE2FS / DEV / FD0 1440

9, how to allow root users to log in remotely

Edit / etc / securetty, plus TTYP2, TTYP3, etc.

Note that there is a serious security problem! It is best to use SSH (secure shell) plus Su / Sudo, and use xTerm's Secure Keyboard to do remote management.

10, what should I do if I forget the root password?

Boot: Linux -s

Bash # Passwd

Change your password!

11, how to cancel the user password

Passwd -d username or direct modification / etc / passwd file to remove the password

12, how to cancel ^ m characters

When you ftp some DOS files to UNIX, you often see an annoying ^ m character behind each line, and two simple methods can cancel it.

Use "VI" to open this file and tap under Command Mode:

:% s / ^ v ^ m //g

Or, knock in the UNIX shell:

SED 'S / ^ V ^ m // g' foo> foo.new

13. Remove LILO information in the guide area

If you install LILO, if there is a change in the number of hard drives, the hard disk will cause the hard disk to be unable to start, and only the floppy disk will start DOS and then run the fdisk / MBR. (This method also clears any guiding area virus)

14. Customize the page to display the content when logging in.

method one:

1. Rename /usR/etc/in.telnetd to in.telnetd.xx (happy with you).

2. Write a shell script replace /usr/etc/in.telnetd, and this Script can perform the work you want before exec /usr/etc/in.telnetd.xx, Banner Graphics is here.

Method Two:

1. Modify /usr/etc/in.telnetd in the "telnet" on /etc/inetd.conf to change to another shell script Full Pathname, from this script to show out Banner graphics, and then execute EXEC / Usr / etc / in.telnetd. It can also extend other methods or modify other daemon or utility.15, and make a prompt with the current path.

For Bash, plus one line in .bashrc:

PS1 = "/ $ PWD // $"

For TCSH, plug in .tcshrc:

Set prompt = "% />"

16, check the information when Linux start

The information displayed when Linux is started. If you see it, you can view it if you are interested in this information, you can use the command dmesg to view after startup.

17, handle a whole directory once

Many common commands of Linux / Unix have a parameter in RM, CP, etc. --- -r, is the meaning of recursive, and the parameters plus parameters can be operated on the target directory and all subdirectories, such as:

RM-RF / TEST (F is Force means forced),

This command completely deletes the subdirectory TEST in the root directory, and the effect is similar to DELTREE under DOS. Of course, be careful when using this command. Rethlean:

CP -R / TEST / TEST1 has a role in XCOPY / S under DOS, and the chgrp command can also be recursively processed by directory, but the parameter is -r, such as:

Chown Ant * -R

18.find command

A. The simplest usage: #find / -name myfile.txt

"/": For the directory to find, if "/" is changed to "." Indicates that it is found in the directory, can also be changed to "/ home", "/ usr / local"

"-name": is a parameter, then pick a space and a file name or directory name

"myfile.txt": The file name to find or the directory name

B. # Find / etc --name '* lang_zh_cn *'

Find content files with "lang_zh_cn"

C. # Find / etc --size 1000c

Find a file greater than 1000bytes, if it is changed to -1000C, it is smaller, changed to 1000C means equal to

转载请注明原文地址:https://www.9cbs.com/read-53310.html

New Post(0)