Most of the information here apply to Ubuntu but they might work on other Linux distors (such as CentOS) as well.
|
Table of Contents
|
General
- Hidden files have a '.' before the file name.
- Most icons are *.svg
- if you hit TAB twice, bash will complete the command name
- The redirection directives, > and » can be used on the output of most commands to direct their output to a file. » appends.
- Ctrl+C (terminates a command) differs from Ctrl+Z(command in background)
Farsi Dictionary
- xfardic = farsi dictionary- dictionary DBs are separate
- stardict is the best
How to write shell scripts
http://www.freeos.com/guides/lsst/ch02sec01.html
Running a *.bin file
First make it executable(chmod +x a.bin) and then run it normally
Set Path
We need to set PATH in .bashrc file in your home to keep something in your path permanently.
Do sudo gedit ~/.bashrc and add export PATH=$PATH:your_directory:another_directory then restart your terminal
Backgammon Game
gnubg
Html Editor
bluefish, kompozer(old name=nvu)
Image Editor
gpaint,gimp
Installations
when we install a package with "sudo make install" then we should be able to uninstall it with "sudo make uninstall"
Fonts
For best result I choose Rendering: "Subpixel smoothing (LCDs)", Smoothing: "Subpixel (LCDs)", Hinting: "Slight", Subpixel Order: "RGB" and Resolution around 89.
Install MS Fonts
Many apps (such as document viewer) will look better now: sudo apt-get install msttcorefonts
Partition Management
gparted for partition management
Spell check in OpenOffice
For open office to spell check the doc you have to install the language specific myspell from synpatic
Mount windows ntfs
mount windows: put /dev/sda1 /media/win ntfs defaults 0 0 in /etc/fstab and then do : mount -a
to see the partitions do fdisk -l
ssh
- "sudo apt-get install ssh" installs both openssh-server and openssh-client.
- To be connected from outside you need to open the port 22 in your firewall as well. Now you can ssh from a Linux machine or use putty from Windows machines.
- Some logs of ssh can be found in /var/log/auth.log or /var/log/secure or you can check the "last" command. Configs are in /etc/ssh.
- Add "PermitRootLogin no" and "MaxAuthTries 3" to the end of config file for security.
- If you get this error: "error: Bind to port 22 on 0.0.0.0 failed: Address already in use." then uncomment "ListenAddress 0.0.0.0" and keep "ListenAddress ::" commented.
- ssh_config is for client and sshd_config is for server (daemon) configuration.
ssh and Filezilla
without below filezilla does not work in ubuntu(7.10)
- sudo apt-get install openssh-server
VGA
when ubuntu does not understand the graphics card or cant find the exact driver for it, it will pick the generic one. then you need to adjust resolution in /etc/X11/xorg.conf sometimes.
if you install nvidia driver then you can configure it using nvidia-settings command.
Anjuta and c/c++
install anjuta with apt and then install autogen from synpatic as well
also need to apt-get install build-essential
This is enough to run anjuta and c compile c files.
Making
For making gnome projects we need to install some more stuff like: automake,autoconf,libtool,intltool,glib-dev,glade-dev,libgnomeui-dev,…
JRE and Firefox
If you want to add your JRE to firefox then in firefox directory (probably /usr/lib/firefox/plugins/) do the following:
ln -s /home/java/jrexxxxxx/plugin/i386/ns7/libjavaplugin_oji.so
and then restart firefox.
Set JAVA_HOME
In .bashrc add export JAVA_HOME=/home/reza/java/jdkxxxx
JavaEE Installation
- chmod +x <the bin file> and got the error:libstdc++.so.5: cannot open shared object file: No such file or directory
- In "/usr/lib" do "sudo ln -s libstdc++.so.6.0.9 libstdc++.so.5" and this solved the issue
MySQL
- Using apt is better : sudo apt-get install mysql-server
- To install mysql administrator: sudo apt-get install mysql-admin
- To install mysql query browser: apt-get install mysql-query-browser
Installing Flash
download, extract and run installer!
Farsi font and firefox:
just do this and restart firefox. Do not change ff settings:
sudo apt-get install ttf-farsiweb xfonts-intl-arabic xfonts-intl-european xfonts-intl-phonetic
wget -c http://heanet.dl.sourceforge.net/sourceforge/fpf/fpf.zip
wget -c http://hezardastan.sourceforge.net/persianfonts/tahoma.tar.gz
wget -c http://hezardastan.sourceforge.net/persianfonts/bfonts.tar.gz
sudo mkdir /usr/share/fonts/truetype/ttf-persian-fonts
sudo unzip fpf.zip -d /usr/share/fonts/truetype/ttf-persian-fonts
sudo tar zxvf tahoma.tar.gz -C /usr/share/fonts/truetype/ttf-persian-fonts
sudo tar zxvf bfonts.tar.gz -C /usr/share/fonts/truetype/ttf-persian-fonts
Install Apache
In apache site there was no install version for Linux. There was just source code that your can make and install (Read this: http://httpd.apache.org/docs/2.2/install.html) or install it the following way. It will be a bit different from what it is in Windows:
sudo apt-get install apache2
sudo /etc/init.d/apache2 restart
- The main configuration file will be located at /etc/apache2/
- Type a2enmod command to see the modules you can install, enable or disable modules
- To install a module: sudo a2enmod proxy_http
- In /mods-enabled/proxy.conf default is Deny and you probably want to change Deny to Allow from all
Apache2 with PHP
You can install Apache2 first and then install php (the version you want for instance php5) using apt-get; it will install related libapache2-mod-php5 packages too. After restarting apache you are ready to go. The php config files are under /etc/php5 in case of version 5. Just put a php file under /var/www/ and test. Also read This.
MySQL with PHP
Read https://help.ubuntu.com/community/ApacheMySQLPHP
Build and Install from Source
You must have the compiler tools installed. They all come with the package build-essential, … in Synaptic.
./configure: To check for dependencies and then create the makefile.
sudo make: To Compile
sudo make install: Normal install
run make clean: To remove the temporary files.
To uninstall the program you run sudo make uninstall.
SVN Client
I use RapidSvn. It is a GUI client for svn. You can install it using apt-get.
Remote Desktop
The best one to work between Windows and Linux is TightVNC.
Get it using sudo apt-get install tightvncserver and run it using tightvncserver command, and for viewer: sudo apt-get install xtightvncviewer.
It also has a Java viewer that can be downloaded from its site. The Java viewer can be run by: java VncViewer HOST 192.168.1.3 PORT 5900
tighvncpsswd for changing password. tightvncserver -kill to kill a server instance.
FTP server
I installed vsftpd. You can configure it in /etc/vsftpd.conf and restart it using /etc/init.d/vsftpd restart.
SFTP (port 22 = SSH port) is more secure than FTP (port 21). In /etc/ftpusers you can find the list of banned ftp users.
Adding Packages to Software Repository
In addition to using menu you can add them directly into /etc/apt/sources.list
Installing Tomcat
I downloaded it from apache site but I was getting "The BASEDIR environment variable is not defined correctly" error although I had CATALINA_HOME in my env. I just did "chmod +x *.sh" in the bin folder of Tomcat and it started working :D
Share Folders Between Ubuntu and Windows
Accessing Ubuntu from Windows XP:
- Install samba on Ubuntu
- Edit /etc/samba/smb.conf
- Add this portion to the end of the file:
[share1]
comment = mi home
path = /home/reza/share
read only = No
guest ok = Yes
- Change the workgroup to your Windows workgroup
- There are a lot of things you can change in this file!
- Now on Windows try \\your-linux-machine and you should be good.
Accessing Windows XP from Ubuntu:
- Just do smb://your-windows-machine
Define DNS in Ubuntu server
In Ubuntu server 8.10 I was unable to find the file /etc/resolv.conf so I created one!! and put my nameservers there like:
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
Then "sudo /etc/init.d/networking restart" and all done! The solves the problem of pinging with computer name.
Define Static IP
Do it in /etc/network/interfaces
Something like this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.xxx
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
Read this: http://www.howtogeek.com/howto/ubuntu/change-ubuntu-server-from-dhcp-to-a-static-ip-address/
How to Change Computer Name
Do it here: /etc/hostname
How to change command prompt
You need to change the PS1 shell variable. This is a simple colorful prompt that suits a black background. It just shows the current path:
PS1=$'\\[\E[0;36m\\]${PWD}\\[\E[1;34m\\]> \\[\E[1;37m\\]'
Add this to the end of your .bash_profile or .bashrc in Ubuntu. Also in Ubuntu you can just simply uncomment "force_color_prompt=yes" from within .bashrc.
See: http://beginlinux.wordpress.com/2008/09/12/modify-your-command-prompt/
Program Launcher
GnomeDo is the best. It can search for files/ programs, etc and run them.
It also has a number of plugins with useful actions. For example a plugin to index pidgin buddies so that you can search them or send them messages, etc.
Also can you Launchy which works best on Windows.
Convert between rpm, tgz and deb
Use alien.
How to open rar files
Install unrar through apt and then you can open rar files either using command line or Gnome Archive Manager (File Roller).
gconf-editor
Gconf-editor is a GUI for gconftool. Gconf-editor gives users the ability to access settings stored in the XML-based GConf configuration database. It is used primarily by developers to debug applications, or by power users to edit hidden and complex settings. It abstracts the values from the GConf database and presents them in an interface similar to Microsoft Windows' registry editor.
Kill processes by name
We list pid of processes by searching their names and then kill them
#!/bin/bash
for i in `ps -C "vuze java" -o pid=`
do
kill -9 $i
done
iptables
- The rules are stored in the file /etc/sysconfig/iptables and are applied whenever the service is started or restarted, including when the machine is rebooted.
- Firewall rules are only valid for the time the computer is on; so, if the system is rebooted, the rules are automatically flushed and reset. To save the rules so that they are loaded later, use the following command: /sbin/service iptables save
**Example: iptables -A chain -j target**
The -A option appends a rule at the end of an existing ruleset. The chain is the name of the chain for a rule.
The three built-in chains of iptables (that is, the chains that affect every packet which traverses a network) are
INPUT, OUTPUT, and FORWARD. These chains are permanent and cannot be deleted. The -j target option specifies
the location in the iptables ruleset where this particular rule should jump. Some built in targets are ACCEPT, DROP, and REJECT.
New chains (also called user-defined chains) can be created by using the -N option. Creating a new chain is useful
for customizing granular or elaborate rules.
| sudo iptables -L | list the current rules |
| sudo iptables —flush | delete all the rules |
Run a script at startup
Add your stuff to /etc/rc.local to be executed after other system initialization scripts.
Adding a service
To create a service from a script add:
#chkconfig: 2345 80 05
#description: James Mail Server
to the start of the script after #!/bin/bash. These lines are needed by chkconfig to determine how to establish the initial runlevels to add the service as well as set the priority for the start-and-stop script execution order.
These lines denote the script will start James server for the runlevels 2, 3, 4 and 5. In addition, the start priority will be set to 80 while the stop priority will be 05. After this do: chkconfig —add the_script





