8 Interesting Linux tips and tricks

Source: Internet
Author: User

We bring you tips and tricks on Linux from time to time. Here we summarize 8 of the most interesting tips and tricks. It is recommended to learn Linux video Tutorials .

List files in their size

If you want a list of files that are sorted based on their size, you can use the following command.

It arranges the files in descending order.

# Ls-l | grep ^-| Sort-nr-k 5 | More

If you want to do the same thing recursively, you can use the second command below.

# LS-LR | grep ^-| Sort-nr-k 5 | More

-sumedh Gajbhiye, [email protected]

Reset the Strange terminal

If you feel your bash terminal incorrectly displays spam prompt character information and displays non-ASCII characters regardless of any command you enter-The following command can get things back on track.

Blind typing in the terminal input: because you actually do not see the correct display of these characters you entered, but even though the input is OK! ) The following command and press ENTER:

# Reset

If that doesn't fix the problem, try the following:

# Stty Sane

-sudheer Divakaran, [email protected]

Record and replay a terminal session

Here is a simple tip to record and replay the terminal playback. It is done by using command script and Scriptreplay.

This is very handy when using terminal authoring tutorials.

To start recording your terminal session, use the following command:

$ script-t 2> timing.log-a output.session

Then enter:

$ ls
$touch Test
.....

$ exit

Here, the script command takes two files as parameter Timing.log (IT records the time information for each command execution) and output.session (stores the output of the command).

Now, to return to the logged session, use the scriptplay shown below.

$ scriptreplay Timing.log output.session

Note: Timing.log and output.session can be used by anyone who wants to replay a session on their own terminal.

-abhishek Singh, [email protected]

Generate random numbers using shell scripts

Sometimes when you want to program with shell scripts, you may need to generate a random number for scripting.

Here is the code to get a 3-bit random number.

var=$ (dd if=/dev/urandom count=1 2>/dev/null | cksum | cut-f1-d "" | Cut-c 3-5);

This time stores randomly generated numbers in a variable named var.

-arpan Chavda, [email protected]
Run the software on Linux as the root user

As a root user, you need to change the GETEUID call to Getppid in the binary file of the software in order for some software that is not running in root to run (typically Google Chrome).

This technique is very useful in the operating system, such as backtrack, where most of the installation work is done by the root user.

For example: To run Google Chrome as root, use the following command:

# Hexedit/opt/google/chome/chrome

Then press Ctrl+s and search for the Geteuid string in the 16 binary dump file. Use String Getppid instead. Press Ctrl+x to save and exit the editor.

The browser is now ready to run as the root user.

# Google-chrome

-mayank Bhanderi, [email protected]

Optimize your site with gzip compression

Compression is a simple and effective way to conserve bandwidth and accelerate your site. With the help of compression, the main page of most sites will change from 100KB to 10KB.

In order to enable this feature in the Apache Web server, you need to include deflate_module in the httpd.conf, and include the following line (/etc/httpd/conf/httpd.conf) in the Apache configuration file to compress the text , HTML, JavaScript, CSS, and XML files:

Addoutputfilterbytype DEFLATE Text/plain
Addoutputfilterbytype DEFLATE text/html
Addoutputfilterbytype DEFLATE Text/xml
Addoutputfilterbytype DEFLATE Text/css
Addoutputfilterbytype DEFLATE Application/xml
Addoutputfilterbytype DEFLATE Application/xhtml+xml
Addoutputfilterbytype DEFLATE Application/rss+xml
Addoutputfilterbytype DEFLATE Application/javascript
Addoutputfilterbytype DEFLATE Application/x-javascript

-munish Kumar, [email protected]
Check server load information when logging in

Here's a tip to check the average server load when you log in to the server. Create a sload.sh text file with the following content:

#!/bin/bash
gh=$ (Uptime | awk-f, ' {print $} ')
Echo-e "Server$gh\n"

Now, to check the server load at login, sload.sh script is called through/ROOT/.BASHRC.

Remember to set script permissions as follows:

# chmod 755/root/sload.sh

To invoke the sload.sh script, append the following after/ROOT/.BASHRC

/root/sload.sh

Or you can append sload.sh content to the. bashrc.

$echo "/root/sload.sh" >>/ROOT/.BASHRC

Once you have completed the above steps, you can log out and log in again to see the server load.

Start your task at a specific time

You can use the following command to schedule your job at a specific time:

# at 2015

> >vlc/music/rockstar.mp3

This command will play the Rockstar.mp3 with VLC player after 2015 hours. You can follow the-l option after the AT command to check for pending jobs:

# at-l

More information on the AT command can be found on the man page.

Do you know these tricks? If you want to learn more, you can entere-Mentor NetworkConsulting Oh!

8 Interesting Linux tips and tricks

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.