Linux Tips and Tricks

Linux Tips and Tricks

Read the CPU Temperature

November8

You can see the current CPU Temperature in the below files

$ ls -l /proc/acpi/thermal_zone/TZS*/temp*
-r–r–r– 1 root root 0 2010-11-08 11:05 /proc/acpi/thermal_zone/TZS0/temperature
-r–r–r– 1 root root 0 2010-11-08 11:05 /proc/acpi/thermal_zone/TZS1/temperature

$ cat /proc/acpi/thermal_zone/TZS0/temperature
temperature:             51 C

$ cat /proc/acpi/thermal_zone/TZS1/temperature
temperature:             52 C
 

posted under Uncategorized | No Comments »

Print the BIOS information

November8

Hi all,

we can use the command called dmidecode to display the BIOS information.

dmidecode is a tool for dumping a computer’s DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks  to  this  table, you  can retrieve this information without having to probe for the actual hardware.  While this is a good point in terms of report speed and safe‐      ness, this also makes the presented information possibly unreliable.

More information :      man dmidecode

Note : You have to execute this command as root.

 

posted under Uncategorized | No Comments »

The Cat Command

November4

 cat

 

Normally we use the cat command to display the small files. And sometimes we use to create a file.

we can use the cat command for the following purpose.

1) Display the line number.

2) Display the end of the line with $

3) squeeze Multiple blanks to one blank line.

4) view tab seperated lines

Now we see the examples.

1) Display the line number.

$ cat test_script.sh
#!/bin/sh
yesterday=`date -d "yesterday" +%Y%m%d`
echo $yesterday

$ cat -n test_script.sh
     1    #!/bin/sh
     2    yesterday=`date -d "yesterday" +%Y%m%d`
     3    echo $yesterday
 

Note : You have to use the -n option with the cat command to display the line numbers.

2) Display the end of the line with $

echo "test" >> Test
echo "" >> Test
echo "testing" >> Test

cat -e Test

test$
$
testing$
 

Note: Every line of the end you can see the letter $. Just create a line with some space and see where the $ symbol goes.

3) squeeze Multiple blanks to one blank line.

The following commands shows that in the testing_file we have some empty lines.

$ cat -n testing_file
     1    test
     2   
     3   
     4   
     5   
     6   
     7   
     8    another line
     9   
    10   
    11   
$ cat -e testing_file
test$
$
$
$
$
$
$
another line$
$
$
$
 

Now use the -s option in the cat command,

-s, –squeeze-blank
              suppress repeated empty output lines

$ cat -s testing_file
test

another line

$
 

4) view tab seperated lines

I created a file called tab_test with tab seperated words.

$ cat tab_test
this    is    tab    seperated    line
testing    for    cat    command
 

Now i am gonna include the -t option with the cat command.

       -T, –show-tabs
              display TAB characters as ^I


$ cat -t tab_test
this^Iis^Itab^Iseperated^Iline
testing^Ifor^Icat^Icommand
$

In the about output you can see the tab space is filled with ^I (cap symbol followd by capital i )

$ echo "this is not tab seperated line" >> tab_test

$ cat -t tab_test
this^Iis^Itab^Iseperated^Iline
testing^Ifor^Icat^Icommand
this is not tab seperated line

 

posted under Uncategorized | No Comments »

Terminal Calculator

November3

In this example, i am gonna to show how to create a Terminal Calculator.

Open your .bashrc file from your home directory (It is a hidden file). Before making changes, please take a backup of the .bashrc file.

Open the file and add the below lines in your end of the .bashrc file.

#calculator function

function calc
{
  echo "${1}" | bc -l;
}

And save the .bashrc file.

Now, just restart your console. and type the below command.

$ calc 5+5
10

$calc 10*5
50
 

If you like to calculate the sine and cosine values, then you have to use it like this

$ calc "s(45)"
.85090352453411842486

$ calc "c(90)"
-.44807361612917015236
 

posted under Uncategorized | No Comments »

Recent Comments

    Categories