Showing posts with label Linux Ubuntu. Show all posts
Showing posts with label Linux Ubuntu. Show all posts

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

Wednesday, October 26, 2011

Ubuntu Remote Desktop

# Let's say you have installed xrdp (in Terminal: sudo apt-get install xrdp) and you have used RDP remote desktop quite a while to connect Windows to Ubuntu or one Ubuntu to another Ubuntu, then you might bump to a problem when you want to install or do some system settings. For example when you want to use synaptic package manager to install something. You will get an error or warning like:
"Failed to run /usr/sbin/synaptic as user root
Unable to copy the users Xauthorization file."
To solve this problem, firstly connect to your Ubuntu using the Remote Desktop Connection (in Windows: Start -> Run -> mstsc (Enter) in order to access the Remote Desktop Application; in Ubuntu: Applications -> Internet -> Terminal Server Client). After you have logged into your Ubuntu, then bring up your Terminal (Ctrl+Alt+T) and type the following instructions:
cd ~
touch ~/.Xauthority
chmod 600 ~/.Xauthority



# When you use one Ubuntu to "remote desktop" to another Ubuntu, there's something that might bother you. In Ubuntu's remote desktop application, there's no auto hide button or menu like Windows Remote Desktop Application that can let you minimize or close the connection. In other words, after you log in to your Ubuntu using full-display, you can only see the remote desktop. But the problem is that you might want to change the full screen mode to a window mode so that you can switch to other window without disconnecting the remote connection.

Here's how to do it, after you have log in to your Ubuntu using the remote desktop application, press Ctrl+Alt+Enter and congratulation you have change the full screen mode to window mode.

Something Useful for Ubuntu New-bee

Below are some of basic settings and information that I think useful for anyone who just started to use Ubuntu.

# First thing to do after you install your Ubuntu:
(1) Set your Internet Connection: On system panel click "System=>Preferences=>Network Connections", add your internet connection either or both in the "Wired" and "Wireless" tab
(2) Update your Ubuntu: On system panel click "System=>Administration=>Update Manager", next click "Check" and then "Install Updates"
(3) Install software that you might need: On system panel click "System=>Administration=>Synaptic Package Manager", type in your root password and Enter, next search the software that you want, for example: "Chromium" (Google Chrome on Ubuntu), on the search result make a tick or check, then click apply button on the top menu, then it will tell you the dependencies that will also be installed together to make it works.

# To remote desktop from Ubuntu to Windows:
(1) On your system panel click "Applications => Internet => Terminal Server Client"
(2) On "Computer" put your IP address or domain name
(3) On protocol Choose "RDP"
(4) Put your username and password, and the rest of the input fields is optional, you can just leave it blank
(5) On second Tab ("Display"), choose "Operate in full screen mode"
(6) Click Connect

# To remote desktop from Windows to Ubuntu:
(1) Open up your "Terminal" by pressing "Ctrl+Alt+T"
(2) Type: "sudo apt-get install xrdp" and Enter your root password
(3) If your windows is Windows XP, then from "Start->Run" type "mstsc" and Enter, next put on your Ubuntu's ip address, if your windows is Windows 7, then click "Start" and type directly "mstsc" and Enter, put on your Ubuntu's ip address

# To change your Ubuntu 10.04 window button that located on left side back to the right side like Windows:
(1) On your desktop Press Alt+F2 to call a "Run Application" pop-up
(2) Type gconf-editor and Enter
(3) go to apps/metacity/general/  then see the right side panel and find the "button_layout"
(4) right click on it and click "Edit Key..." Change the value to "menu:minimize,maximize,close" and click "OK"
(5) Done!

# To enable typing Chinese Character with Pinyin input method:
(1) From your panel menu "System -> Preferences -> Keyboard Input Method (or iBus Preferences)"
(2) Find "Font and Style" and on the "Show language panel:" set the value to "Always"
(3) Enable following options: "Show icon on system tray", "Show input method name on language bar", "Embed preedit text in application window".
(4) Next, Go to the second tab "Input Method" and select an input method "Chinese -> Pinyin" and Click "Add" then Close
(5) Open a browser or a notepad or anything that you can use your keyboard to type, on your system panel find an icon like keyboard, click on it and choose "Chinese - Pinyin", then you will see the language panel and there you can adjust your preferences.

For more detail description with pictures:
http://www.pinyinjoe.com/linux/ubuntu-10-chinese-input-pinyin-chewing.htm

# Some useful Shortcut Keys:
(1) Ctrl+Alt+T : open up "Terminal"
(2) Ctrl+Alt+L: lock your screen
(3) Ctrl+Alt+D: show desktop
(4) Alt+Tab: change windows
(5) Alt+F4: close a window

For more complete list of shortcut key:
http://maketecheasier.com/useful-shortcut-keys-in-ubuntu/2008/07/14