Saturday, July 18, 2009
share the internet connection in linux 8:34 AM
first of all lets look at the topology of network we are going deal with.
{internet}-----(XXX0 / 10.0.0.1)-> PC-A -(YYY0/192.168.0.1)-----------(ZZZ0/192.168.0.2)-> PC-B
We need to share the internet connection to PC-B from PC-A. PC-A is directly connected to the internet via an network interface (such as eth0 or wlan0 or ppp0). We take that interface as XXX0. But please make sure to change the XXX0 to the appropriate network interface which u are connected to the internet.
same as that PC-B is connected to PC-A via interfaces YYY0, ZZZ0 respectively. Once again please make sure you substitute the interface names with the appropriate interface names of yours. (you can check the interface names by ifconfig command)
The architecture of sharing the internet is not hidden in the linux as microsoft does in thier OS. So we should enable the NAT in the internet connected PC, which works as a NAT router. and we should also enable the remote packet forwarding too. This is by default disabled. Now lets work it out...
1) Change to root (this is a must)
su - root
2) Enable IP forwarding
echo "1" > cat /proc/sys/net/ipv4/ip_forward
edit /etc/sysctl.conf
and set.....
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
3) Configure NAT functionality
- remove excisting IPTABLE entries
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X
- Now save the iptables rules
service iptables save
service iptables restart
- Set the nat assuming the internet interface is XXX0
iptables -t nat -A POSTROUTING -o XXX0 -j MASQUERADE
service iptables save
service iptables restart
4) Restart network
service network restart
here we go click the PC-Bs web browser and surf the internet.. Enjoy.
Linux is beautiful. And it gives us the real feeling of working on it. Coz we configure it for our own style. This tutorial is for novice users. For next level of linux users they can utilize the above setting according to their needs.
Monday, May 25, 2009
Create a recycle bin for linux console 11:25 PM
- Create the .junk folder in the /etc/skel directory.
The content in this directory is copied in to the user home directory when the new user is created. This technique can be used to create the .junk directory in the users home directory.
login as the root
$ su - root
password :
#
create the .junk directory
# mkdir /etc/skel/.junk - The envioromental variabble we create is WASTEBIN.
The value of the variable will be $HOME/.junk - this enables the user to call the recycle bin directory from the command line.
edit the file .bash_profile which is executed when the user logs in
# vi /etc/skel/.bash_profile
in that file add at the bottom
export WASTEBIN=$HOME/.junk - The command that we create is "del" this is alias to "rm" command.
edit the .bashrc file
# vi /etc/skel/.bashrc
and append this text to that file to make an alias. add this to the file bottom
alias rm=del - design the "del" command
In shell(bash) $1, $2, $3... $9 are the nine bash commanline arguments. So we use this predefine variables to pass the values to the "del" command.
we can also use $* variable, which represent all those 9 variables at once. so the del command would be in the following format
del....
create the file#
# vi usr/local/bin/del
then add
mv $* $WASTEBIN - change the execution permission to the del command
# chmod +x /usr/local/bin/del
Sunday, May 24, 2009
download Fedora 10 5:03 AM
Fedora-10-i386-disc1.iso 19-Nov-2008 17:02 687M
Fedora-10-i386-disc2.iso 19-Nov-2008 17:02 674M
Fedora-10-i386-disc3.iso 19-Nov-2008 17:03 676M
Fedora-10-i386-disc4.iso 19-Nov-2008 17:03 691M
Fedora-10-i386-disc5.iso 19-Nov-2008 17:04 687M
Fedora-10-i386-disc6.iso 19-Nov-2008 17:04 80.1M
Fedora-10-i386-DVD.iso 19-Nov-2008 16:56 3493M
Fedora-10-i386-netinst.iso 19-Nov-2008 16:53 129M
x86 64
Fedora-10-x86_64-disc1.iso 19-Nov-2008 18:29 688M
Fedora-10-x86_64-disc2.iso 19-Nov-2008 18:29 690M
Fedora-10-x86_64-disc3.iso 19-Nov-2008 18:29 688M
Fedora-10-x86_64-disc4.iso 19-Nov-2008 18:30 688M
Fedora-10-x86_64-disc5.iso 19-Nov-2008 18:31 691M
Fedora-10-x86_64-disc6.iso 19-Nov-2008 18:31 534M
Fedora-10-x86_64-DVD.iso 19-Nov-2008 18:21 3979M
Fedora-10-x86_64-netinst.iso 19-Nov-2008 18:17 130M
Linux Principles 1:47 AM
Everything is a file (including hardware)
- in linux everything is a file including the hardware. There are three types of files
text file
Binary file
Device file - hardware representatives
Small, single-purpose programs
- small is beautifull concept
Ability to chain programs together to perform complex tasks
- in other word.. its called piping. "|"
example
cat /etc/passwd | cut -f1 -d :
this will read the file /etc/passwd and the content is cut with the delemeter ":" and the 1st part is shown
Avoid captive user interfaces
- the basic work in linux is done in command. The GUI is the graphical representative of the command line execution.
Configuration data stored in text
- all configurations are stored in plain text files
example
cat /etc/resolve.conf
this will show the DNS database stored in linux. The name list is stored in plain text in the file /etc/resolve.conf
Change password in linux 1:34 AM
Current Password:
New Password:
Confirm New Password:
Each of these prompts must be entered and entered correctly for the password to be successfully changed.
passwd newperson
If you have just setup an account using the useradd command you would then type a command similar to the above command to set the password for the "newperson" account. Only root users have the ability to set passwords for other accounts.
basic linux commands 12:53 AM
cat | Sends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping. | |
cat .bashrc | Sends the contents of the ".bashrc" file to the screen. | |
cd | Change directory | |
cd /home | Change the current working directory to /home. The '/' indicates relative to root, and no matter what directory you are in when you execute this command, the directory will be changed to "/home". | |
cd httpd | Change the current working directory to httpd, relative to the current location which is "/home". The full path of the new working directory is "/home/httpd". | |
cd .. | Move to the parent directory of the current directory. This command will make the current working directory "/home. | |
cd ~ | Move to the user's home directory which is "/home/username". The '~' indicates the users home directory. | |
cp | Copy files | |
cp myfile yourfile | Copy the files "myfile" to the file "yourfile" in the current working directory. This command will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning if it exists. | |
cp -i myfile yourfile | With the "-i" option, if the file "yourfile" exists, you will be prompted before it is overwritten. | |
cp -i /data/myfile . | Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt before overwriting the file. | |
cp -dpr srcdir destdir | Copy all files from the directory "srcdir" to the directory "destdir" preserving links (-p option), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another directory. | |
dd | dd if=/dev/hdb1 of=/backup/ | Disk duplicate. The man page says this command is to "Convert and copy a file", but although used by more advanced users, it can be a very handy command. The "if" means input file, "of" means output file. |
df | Show the amount of disk space used on each mounted filesystem. | |
less | less textfile | Similar to the more command, but the user can page up and down through the file. The example displays the contents of textfile. |
ln | Creates a symbolic link to a file. | |
ln -s test symlink | Creates a symbolic link named symlink that points to the file test Typing "ls -i test symlink" will show the two files are different with different inodes. Typing "ls -l test symlink" will show that symlink points to the file test. | |
locate | A fast database driven file locator. | |
slocate -u | This command builds the slocate database. It will take several minutes to complete this command. This command must be used before searching for files, however cron runs this command periodically on most systems. | |
locate whereis | Lists all files whose names contain the string "whereis". | |
logout | Logs the current user off the system. | |
ls | List files | |
ls | List files in the current working directory except those starting with . and only show the file name. | |
ls -al | List all files in the current working directory in long listing format showing permissions, ownership, size, and time and date stamp | |
more | Allows file contents or piped output to be sent to the screen one page at a time. | |
more /etc/profile | Lists the contents of the "/etc/profile" file to the screen one page at a time. | |
mv | Move or rename files | |
mv -i myfile yourfile | Move the file from "myfile" to "yourfile". This effectively changes the name of "myfile" to "yourfile". | |
mv -i /data/myfile . | Move the file from "myfile" from the directory "/data" to the current working directory. | |
pwd | Show the name of the current working directory | |
shutdown | Shuts the system down. | |
shutdown -h now | Shuts the system down to halt immediately. | |
shutdown -r now | Shuts the system down immediately and the system reboots. | |
whereis | Show where the binary, source and manual page files are for a command | |
whereis ls | Locates binaries and manual pages for the ls command. |