An excellent and powerful feature about Ubuntu or any other Linux machines is that you can do anything/everything with a single command in a terminal. As with great powers comes great responsibility of understanding(possible) and remembering(absolutely impossible) those powerful commands! So this post would have simple and sometimes complex(which I doubt) commands for working your way around Ubuntu. Please contribute to this list, if you wish. Thanks in advance.
commands:
Install eclipse | sudo apt-get install eclipse |
Uninstall eclipse | sudo apt-get autoremove eclipse |
Copy entire directory in Ubuntu | cp -r src_path/folder/* dest_path |
Install LAMP stack | sudo apt-get install lamp-server^ - ^ cadet symbol is mandatory |
Restart/Start/Stop Apache | sudo /etc/init.d/apache2 restart/start/stop |
Install phpmyadmin | sudo apt-get install libapache2-mod-auth-mysql phpmyadmin |
Cleaning up after any uninstall | sudo apt-get autoremove |
Start/Stop MySql | /etc/init.d/mysql start/stop |
Create softlink for phpmyadmin in Ubuntu 10.04(access as http://localhost/pma/index.php) | sudo ln -s /usr/share/phpmyadmin /var/www/pma |
Open folder as root user - AVOID this and prefer using terminal and sudo for executing commands | gksudo nautilus |
Print out processor information | cat |
To find out if 32 bit or 64 bit linux kernel | uname -a - if result has i386/i486/i586/i686 GNU/LINUX, then 32 bit or x86_64 GNU/Linux, then 64 bit |
To view .chm files in Ubuntu - chm = Microsoft compiled HTML files format | Just to read use "xchm"(sudo apt-get install xchm). To edit the file and republish in different format, follow the source here. |
To find the version of JDK in your linux | "java -version" |
To create aliases for often used complex commands | Cmd: alias alias_name="alias_cmd --options".If you got more aliases and you need it for all sessions hereafter, create a file "./alias" (name is for your reference, any name should do) in home directory. Add all the aliases command you need.Add the following lines in file $HOME/.bashrc, # Source the aliases, if a separate file existsand execute "source $HOME/.bashrc". Source here. |
To change password for a user account | cmd: "passwd". You will be prompted to enter current, new and retype new password. It should be more than 6 char long. |
To change login shell | Find the current shell, "echo $SHELL", the env variable has the current shell info. Then find list of valid shell logins for your system by "cat /etc/shells". Finally to change to new shell, "chsh -s newshell" where newshell is the full pathname taken from /etc/shells. You will be prompted for password. It will take effect from next login. |
To clear the contents of a file without deleting it | We know "cat filename" - print the file on terminal, "nano filename" - to edit line by line, "> filename" - clear the contents of the file without destroying the file. |
To use gcc-3.x version instead of default gcc in Ubuntu in 10.04 | You need to download required 3.x version, I need 3.4 so I downloaded gcc-3.4-base, cpp-3.4, and gcc-3.4 Then "sudo dpkg -i *.deb", this would select the removed databases and install the gcc. Your default gcc would still be the same and both version co-exist. While compiling just use "gcc-3.4". Note: "gcc -v" displays the version of gcc. |
To execute user defined script from any directory in any session | Lets say you got a script named "first" and you want to execute the script just like other linux commands like "echo" from anywhere at shell prompt. In short, you need to add your bin directory to the PATH env variable. Thats what exactly we do here: 1. "mkdir bin" --> in your home directory create a directory called bin . Its a good practice to use "bin" folder to store your scripts. 2. "cp first ~/bin" --> copy all your tested script files to the bin directory. 3. "cd" --> go to root directory, thats where you can find .bash_profile. 4. "vi .bash_profile" --> open the profile in vi editor. This file has all startup settings. 5. "export PATH=$PATH:~/bin" -->append the path of bin directory to env variable PATH so system can find the executable. Don't forget the ":" and replace "~" with full path to your directory if you are using other directory than your home. Save the vi file using " 4. "first" --> it should work from any directory of the user. |
How to install apache server | In terminal: "sudo apt-get install apache2". This would install,configure the server for you. To check in browser, "http://localhost" |
How to open "rar"/"zip" files | 1. First install "sudo apt-get install unrar". Then "unrar x filename.rar" where filename.rar = your file2. To unzip files, in terminal "unzip filename". -d option specifies the target directory for the files. |
Create alias ip address in Linux | "ifconfig INTERFACE:ctr IP_ADDR netmask 255.255.255.0 up"Exp: INTERFACE - the interface in which you want to add the new ip address. ctr - start from 0 and increment for every new alias ip. IP_ADDR - the new alias ip address you want to add. netmask, up - keywords mandatory. Calculate the netmask and update it. If i want to add 192.168.30.10 to eth1 the command would be "ifconfig eth1:0 192.168.30.10 netmask 255.255.255.0 up". |
To display unix timestamp | "date" displays the date and time. If you want the unix timestamp use "date +%s". Eg: For Mon Jan 24 21:42:57 PST 2011, the timestamp is 1295934173. Use this site to find out timestamp given date and time. |
How to find version of Tomcat | 1. "cd $TOMCAT_HOME/bin" -->Go to TOMCAT_HOME - root folder of tomcat installation 2. "sh version.sh" -->will print out the version details of tomcat, jdk |
How to open new terminal and execute commands from a terminal | The command is "screen". In the old terminal, "screen command_to_execute" will open up terminal inside this one. Look here for options to detach the new terminal. |
/tr> | |
P.S: Usually blogger has a bugging problem of inserting unwanted spaces if you insert a table in Edit Html section. To avoid the pitfall, after pasting the table code, remove all the spaces. Hence the code like this (avoiding printing it as table)
table
tbody
tr
td /td
tr
/tbody
table
After removing the extra spaces would look like this,
table tbody tr td /td /tr /tbody /table
Now the code looks confusing, so better edit the table with spaces and finally before publishing it remove the spaces. Hope this helps someone!