Tips for Linux

Source: Internet
Author: User
Tags i18n
1. Change the Host Name
Add HOSTNAME = host name in the/etc/sysconfig/network File
$ Hostname: Host Name.

2. mount
Mount-o codepage = 936, iocharset = cp936, gb2312, utf8

3. delete an object 0 in size
Rm-I 'Find./-size 0' or
Find./-size 0-exec rm {}/; or
Find./-size 0 | xargs rm-f or
For file in *
Do
If [! -S $ file]
Then
Rm $ file
Echo "rm $ file success! "
Fi
Done

4. Set scroll wheel and mouse
Change PS/2 in/etc/X11/Xf86Config to ImPS/2.

5. tar volume compression and merge (MB)
Tar cvzfp-mytarfile | split-B 500 m
Cat x *> mytarfile.tar.gz

6. merge two files
1) retrieve the collection of two files (only one copy is retained for repeated rows) cat file1 file2 | sort | uniq
2) extract the intersection of the two files (leaving only the duplicate rows of the two files at the same time) cat file1 file2 | sort | uniq-d
3) Delete the intersection and leave other lines cat file1 file2 | sort | uniq-u

7. Set the com1 port so that the Super Terminal can log on through the com1 port.
Confirm/sbin/agetty, edit/etc/inittab, and add
7: 2345: respawn:/sbin/agetty/dev/ttyS0 9600
9600bps is because the rate is generally set by default for a vro. It can also be set to 57600, 115200, or.
Modify/etc/securetty and add a line: ttyS0 to ensure that the root user can log on.

8. startx starts gnome or KDE
Edit file ~ /. Xinitrc added
Exec gnome-session or exec startkde, and then use startx.

9. Change the redhat System Language/Character Set
Modify the/etc/sysconfig/i18n File
LANG = "en_US"
LANG = "zh_CN.GB18030"
Or modify ~ /. I18n
LANG = "zh_CN.GB18030"
Or
~ /. Bashrc
Export LANG = zh_CN.GB2312

10. Set the screen to 90 Columns
Stty cols 90

11. md5sum
Md5sum file> md5 to generate an md5 code
Md5sum-c md5 check file

12. Find the file with the S permission.
Find-type F/(-Perm 04000-o-Perm 02000/)-exec LS-l {}/;

13. pop up the CD
Eject/mnt/CDROM
Reclaim
Eject-T/mnt/CDROM

14. Set the time
Date-s "2003-05-18 CST" CST indicates the time zone
Time Setting: Date-S
After modification, execute clock-W to write to CMOS.
Hwclock -- systohc

15. Search for files in multi-level Directories
Find./Dir-name file-print
Du-A | grep-I file
Locate filename

16. After installation, use ISO to add and delete the RPM package.
RedHat-config-packages -- isodir =

17. editing the inittab file takes effect directly.
Init Q

18. Install grub into MBR
Grub> root (ha0, 0)
Grub> setup (hd0)
Or install grub-install/dev/hda.

19. Disable PC speakers in text
In/etc/inputrc
Set bell-style none
Or
Echo "set bell-style none" >> ~ /. Bashrc

20. ls only lists Directories
Ls-lF | grep ^ d
Ls-lF | grep/$
Ls-F | grep ^ d

21. ctrl + s and ctrl + q
Ctrl + s pause sending data to the terminal
Ctrl + q restore

22. delete the file containing the specified string in the directory.
Find dir-type f-exec grep "string" {}/;-print-exec rm {}/;

23. gs merge two ps or PDF files
Gs-q-dNOPAUSE-dBATCH-sDEVICE = pswrite-sOutputFile = bar. ps-f part1.ps part2.ps
Gs-q-dNOPAUSE-dBATCH-sDEVICE = paiwrite -soutputfile?bar=- f part1.pdf part2.pdf

24. vim does not ring the bell
Echo "set vb t_vb" >> ~ /. Vimrc

25. Start or close the service
Ntsysv -- level n
Chkconfig -- list all services
Chkconfig name on/off enable or disable the service name

26. Change IP Address
Ifconfig eth0 ip netmask ip
Then modify IPADDR in the/etc/sysconfig/network-scripts/ifcfg-eth0 File

27. Change the default gateway
Route add default GW gateway IP Address
Edit gateway in the/etc/sysconfig/network-scripts/ifcfg-eth0 File
You can also change the subnet mask and network card hardware address.

Hwaddr = 00: E0: 81: 21: 01: 26
Ipaddr = 159.226.119.111
Netmask = 159.226.119.192
Gateway = 159.226.119.126

28. Check what programs are running on port 22.
Lsof-I: 22

29. Change DNS
Edit nameserver dnsip in the/etc/resolv. conf file

30. Modify the MAC address
/Sbin/ifconfig eth0 down
/Sbin/ifconfig eth0 HW ether 00: AA: BB: CC: DD: EE
/Sbin/ifconfig eht0 up

31. Change the default system configuration.
Sysctl-W net. ipv4.ip _ default_ttl = N
Or edit the file.
/Etc/sysctl. conf
Net. ipv4.ip _ forward = 0
View the changes using the sysctl command
Sysctl-

32. Ssh configuration file
/Etc/ssh/sshd_config
Permitrootlogin no/yse
Allow root users to log on via SSH
Port 2222 changes the sshd Port

33. allow root Telnet
Edit file/etc/securetty added
PTS/0
PTS/1
Change telnet port
In/etc/services, the corresponding port of teknet is changed from 21 to the desired port.

34. Bind two IP addresses to one network card
CD/etc/sysconfig/network-Scripts
CP ifcfg-eth0 ifcfg-eth0: 1
Modify ifcfg-eth0: 1 change IP and device name

35. bind an IP address to two NICs
IP: 192.168.0.88
Gateway: 192.168.0.1

/Sbin/modprobe bonding miimon = 100 mode = 1
/Sbin/ifdown eth0
/Sbin/ifdown eth1
/Sbin/ifconfig bond0 192.168.0.88
/Sbin/ifenslave bond0 eth0 eth1
/Sbin/route add default GW 192.168.0.1

36. Immediately enable Linux to support NAT
Echo 1>/proc/sys/NET/IPv4/ip_forwar
Iptables-T nat-I postroutine-J Masquerade

37. Simple route settings
View route settings
Netstat-Rn
Route-n
Manually add a route
Route add-net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1
Manually delete a route
Route del-net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1
Modify the/etc/sysconfig/static-routes file to add a route
Any net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1

38. Add the default lib LIBRARY PATH
Export ld_libary_path = $ ld_libary_path:/usr/local/lib
Write ~ /. Bashrc
Or add it to/etc/lD. So. conf.
/Usr/local/lib: Execute ldconfig.

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.