Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the interesting tips and tips in Linux?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you some interesting tips and skills related to Linux, which are detailed in content and clear in logic. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

List files by their size

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

It sorts 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, sumedh.gajbhiye1985@gmail.com

Reset a strange terminal

If it feels like your bash terminal incorrectly displays junk prompt characters and displays non-ASCII characters no matter what command you enter-the following command will get things back on track.

Type blindly at the terminal because you can't actually see the correct display of the characters you typed, but just type it! ) and press enter:

# reset

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

# stty sane

-Sudheer Divakaran, cdsudheer@gmail.com

Record and play back the terminal session

Here is a simple tip to record and play back terminal playback. It is done by using the commands script and scriptreplay.

This is very convenient when using the terminal to make tutorials.

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

$script-T2 > timing.log-an output.session

Then enter:

Touch test... ..

$exit

Here, the script command takes two files as arguments timing.log (which records the time of execution of each command) and output.session (which stores the output of the command).

Now, to return to the recorded 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 the session on their terminal.

-Abhishek Singh, abhishekkumarsingh.cse@gmail.com

Use shell script to generate random numbers

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

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

Var=$ (dd if=/dev/urandom count=1 2 > / dev/null | cksum | cut-F1-d "" | cut-c 3-5)

This time the randomly generated numbers are stored in a variable named var.

-Arpan Chavda, 09bce006@nirmauni.ac.in runs software on Linux as root user

As a root user, in order for some software that cannot be run as root to run, you need to change the geteuid call to getppid in the software binaries.

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

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 hex dump. Replace with the string getppid. Press Ctrl+X to save and exit the editor.

Now the browser can run as a root user.

# google-chrome

-Mayank Bhanderi, mbhanderi24@gmail.com

Optimize your site with gzip compression

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

To enable this feature in the Apache Web server, you need to include deflate_module in httpd.conf and add the following line (/ etc/httpd/conf/httpd.conf) to the Apache configuration file to compress the text, html, javascript, css, and xml files:

AddOutputFilterByType DEFLATE text/plainAddOutputFilterByType DEFLATE text/htmlAddOutputFilterByType DEFLATE text/xmlAddOutputFilterByType DEFLATE text/cssAddOutputFilterByType DEFLATE application/xmlAddOutputFilterByType DEFLATE application/xhtml+xmlAddOutputFilterByType DEFLATE application/rss+xmlAddOutputFilterByType DEFLATE application/javascriptAddOutputFilterByType DEFLATE application/x-javascript

-Munish Kumar, munishtotech@gmail.com checks server load information when logging in

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

#! / bin/bashgh=gh\ n "

Now, to check the server load when logging in, call the sload.sh script through / root/.bashrc.

Remember to set script permissions as follows:

# chmod 755 / root/sload.sh

To invoke the sload.sh script, append / root/.bashrc as follows

/ root/sload.sh

Or you can append the contents of sload.sh to .bashrc.

$echo "/ root/sload.sh" > > / root/.bashrc

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

Start your mission at a specific time

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

# at 2015

> > vlc / music/rockstar.mp3

This command will play rockstar.mp3 using the vlc player after 2015 hours. You can check for pending assignments by following the-l option after the at command:

# at-l

More information about the at command can be found on the man page.

These are all the contents of this article entitled "what are the interesting tips and tips in Linux". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report