Wednesday, November 9, 2011

Useful Linux Terminal Commands

lsb-release (Linux Standard Base - Release)
- Print your linux distribution-specific information
for example:
# lsb-release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.10
Release:        11.10
Codename:       oneiric


iwlist (Wireless Interface list)
- Get more detailed wireless information from a wireless interface

This is useful when you use Ubuntu on your laptop and you want to connect to the wireless network but you don't know the SSID of the available APs (Access Points) around you.

Example:
# sudo iwlist wlan0 scan

wlan0     Scan completed :
          Cell 01 - Address: 54:E6:FC:E6:62:B8
                    Channel:3
                    Frequency:2.422 GHz (Channel 3)
                    Quality=42/70  Signal level=-68 dBm
                    Encryption key:off
                    ESSID:"cse_f5011"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=000000bb0a5b09de
                    Extra: Last beacon: 48ms ago
                    IE: Unknown: 00096373655F6635303131
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030103
                    IE: Unknown: 2A0102
                    IE: Unknown: 32043048606C
                    IE: Unknown: DD180050F2020101860003A4000027A4000042435E0062322F00
                    IE: Unknown: DD1E00904C334E101BFFFF000000000000000000000000000000000000000000
                    IE: Unknown: 2D1A4E101BFFFF000000000000000000000000000000000000000000
                    IE: Unknown: DD1A00904C3403051B00000000000000000000000000000000000000
                    IE: Unknown: 3D1603051B00000000000000000000000000000000000000
                    IE: Unknown: DD0900037F01010000FF7F
                    IE: Unknown: DD0A00037F04010000004000
          Cell 02 - Address: 00:02:2D:2A:3E:DF
                    Channel:8
                    Frequency:2.447 GHz (Channel 8)
                    Quality=58/70  Signal level=-52 dBm
                    Encryption key:off
                    ESSID:"WaveLAN Network"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s
                    Mode:Master
                    Extra:tsf=0000000001dd3a38
                    Extra: Last beacon: 6380ms ago
                    IE: Unknown: 000F576176654C414E204E6574776F726B
                    IE: Unknown: 010482848B96
                    IE: Unknown: 030108
                    IE: Unknown: 800600601D003600



ldconfig (Load Configuration)
- Configure dynamic linker run-time bindings

ldconfig  creates,  updates, and removes the necessary links and cache (for use by the run-time linker, ld.so) to the most recent shared librariesfound in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/usr/lib and /lib).  ldconfig checks the header and file names of the libraries it encounters when determining which versions should have their links updated.  ldconfig ignores symbolic links when scanning for libraries.


">" (greater sign)
-Redirecting Output

Redirection of output causes the file whose name results from the expansion of word to be opened for writing on file descriptor n, or the standard output (file descriptor 1) if n is not specified. If the file does not exist it is created; if it does exist it is truncated to zero size.

The general format for redirecting output is:
[n]>word

If the redirection operator is >, and the noclobber option to the set builtin has been enabled, the redirection will fail if the file whose name results from the expansion of word exists and is a regular file. If the redirection operator is >|, or the redirection operator is > and the noclobber option to the set builtin command is not enabled, the redirection is attempted even if the file named by word exists.  


">>" Appending Redirected Output

- Use to append the redirected output to the designated file
for example:
# echo "test" >> testFile.txt
if the original testFile.txt has content:
abc
then the result will be:
abc
test

Redirection of output in this fashion causes the file whose name results from the expansion of word to be opened for appending on file descriptor n, or the standard output (file descriptor 1) if n is not specified. If the file does not exist it is created.

The general format for appending output is:
[n]>>word


mkdir -p (Make multiple sub directories with parent directories)
-Make directory with also sub directory and no error if sub directory is existing and make parent directories as needed
E.g.:
# mkdir -p /home/test/dir1/{public,private,log,backup}



zip -r (Compress File(s))
-Compress a directory to a zip file
E.g.: 
To zip directory called images in your home directory (/home/username/images), type the following command:
# zip -r myimages.zip /home/you/images/


It recurses into directories (all files and directories inside pics) to produced zip file called myimages.zip


unzip
-Unzip or extract your .zip file

No comments:

Post a Comment