Showing posts with label commande line. Show all posts
Showing posts with label commande line. Show all posts

Monday, 10 February 2014

DNS Settings on Linux

  1. watch video

 2

Manual DNS

There may be times you need to change your server's DNS settings, either because you find they're misconfigured or because you want to use your own. Fortunately there isn't a lot of work involved in changing the DNS servers, just a quick edit in the right place.

resolv.conf

On Linux the DNS servers the system uses for name resolution are defined in the file:
/etc/resolv.conf
It's spelled just like that, with no "e" at the end of "resolv".
In that file we'll want to have at least one "nameserver" line (two is better, so we have a fallback). Each line defines a DNS server.
The name servers will be prioritized in the order the system finds them in the file. Use the IP addresses of the name servers when entering them, since the system won't know what to do with domain names until after it knows how to get to the DNS servers.
Open resolv.conf with an editor like nano to make the necessary changes (if it doesn't exist already this will create the file for us):
sudo nano /etc/resolv.conf

Rackspace Cloud Hong Kong

If your Cloud Server is in the Hong Kong (HKG) datacenter you should use:
nameserver 120.136.32.63
nameserver 120.136.32.62

Rackspace Cloud UK

If you're on Rackspace Cloud UK you can use our closest DNS servers by making the contents of the /etc/resolv.conf file read:
nameserver 83.138.151.80
nameserver 83.138.151.81

Rackspace Cloud USA - ORD

If your Cloud Server is in the US Chicago (ORD) datacenter you should use:
nameserver 173.203.4.8
nameserver 173.203.4.9

Rackspace Cloud USA - DFW

If your Cloud Server is in the US Dallas/Fort Worth (DFW) datacenter you should use:
nameserver 72.3.128.240
nameserver 72.3.128.241

Rackspace Cloud AUS - SYD

If your Cloud Server is in the Sydney, Australia datacenter you should use:
nameserver 119.9.60.63
nameserver 119.9.60.62

A quick test

Once you have your DNS servers set, save the file. And you're done. No reboot required.
The easiest way to make sure your new settings are good ones is to try to ping a domain name:
ping -c 3 rackspace.com
You should see a result like:
PING rackspace.com (173.203.44.122) 56(84) bytes of data.
64 bytes from 173.203.44.122: icmp_req=1 ttl=249 time=25.3 ms
64 bytes from 173.203.44.122: icmp_req=2 ttl=249 time=25.2 ms
64 bytes from 173.203.44.122: icmp_req=3 ttl=249 time=25.2 ms
 
--- rackspace.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 25.236/25.292/25.392/0.147 ms
If you get an "unknown host" message back you should double-check the IP addresses you set as your DNS servers.

IPv6

If you're using IPv6 on your server you may need to add the IPv6 addresses of your name servers to resolv.conf.  You can see if a DNS server has an IPv6 address with two steps.
First, use "host" to get the name of the server:
$ host 72.3.128.240
240.128.3.72.in-addr.arpa domain name pointer cachens1.dfw1.rackspace.com.
Then use the domain name you got back in another "host" lookup:
$ host cachens1.dfw1.rackspace.com
cachens1.dfw1.rackspace.com has address 72.3.128.240
cachens1.dfw1.rackspace.com has IPv6 address 2001:4800:d::1
If an IPv6 address is returned you can add that as another "nameserver" line in resolv.conf, as in:
nameserver 2001:4800:d::1
Then test as above, using the "ping6" command instead of the regular "ping" command to force the system to use IPv6.

Summary

It's that simple - change or add those name servers and once the settings are saved the system will use them right away. Make sure the changes take with a quick ping to test it and you'll be done.

Monday, 30 December 2013

basic linux commands

 basic linux commands

basic linux commands

hi guys, hiyou have installed your favorite linux distro and you are sitting in front of it. Probably you must have heard a lot of frightening things about its console. Here you will see some basic linux commands which will help you to get familiar with linux command line. So let's continue with the linux commands cheatsheet.
But first a few words about a very basic command called man. man comes from manual and it works like this man command_name. With this command you can view information on how to use any command of your system. There is even a man page for man! Try typing man man and you ll get the point. So if want further information and details on a command listed below just type man command_name
Lets get started!
 basic linux commands
basic linux command line

Viewing, copying, moving and deleting files

ls Display the contents of the current directory
ls -a Display also hidden files and hidden directories
cp filename /path/dir_name Copy filename into directory /path/dir_name
cp -r dir_name /path/dir_name2 Copy the entire dir_name into /path/dir_name2
cp filename1 filename2 /path/dir_name Copy filename1 and filename2 into /path/dir_name
rm name Remove a file or directory called name
rm -r name Remove an entire directory as well as its included files and subdirectories
mv filename /path/dir_name Move filename into /path/dir_name
mv filename1 filename2 Rename filename1 to filename2
cat filename Display filenames contents
more filename Display filename in pages. Use spacebar to view next page
head filename Display filenames first 10 lines
head -15 filename Display filenames first 15 lines
tail filename Display filenames last 10 lines
tail -15 filename Display filenames last 15 lines
pwd Display current directory
cd /path/dir_name Change to directory /path/dir_name
cd .. Go 1 directory up
mkdir dir_name Create directory dir_name
rmdir dir_name Delete directory dir_name
 

Finding files and text within files

updatedb Update (create first time used) a database of all files under the root directory /
locate filename Find file filename searching in the database
find / -name filename Starting from the root directory search for the file called filename
find / -name *filename Same as above but search for file containing the string filename
grep string /path/dir_name Starting from /path/dir_name search for all files containing string
which application_name Search $path for application app_name
whereis application_name Search $path, man pages and source files for application_name
  basic linux commands

Archived files

Decompress

tar -xzf filename.tgz Decompress tzg file
tar -xzf filename.tar.gz Decompress tar.gz file
tar -xjf filename.tar.bz2 Decompress tar.bz2 file
 
Compress
tar -czf filename.tar /path/dir_name Compress directory /path/dir_name to filename.tar
gzip -c filename > filename.gz Compress /path/dir_name to filename.tar.gz
bzip2 -c filename > filename.bz2 Compress /path/dir_name to filename.tar.bz2
  basic linux commands

Using rpm files 

rpm -hiv package.rpm Install rpm called package.rpm
rpm -hiv --force package.rpm Install rpm called package.rpm by force
rpm -hUv package.rpm Upgrade rpm called package.rpm
rpm -e package.rpm Delete rpm called package.rpm
rpm -qpil package.rpm List files in not-installed rpm called package.rpm
rpm -ql package.rpm List files in installed rpm called package.rpm
rpm -q str List installed rpms containing the string str
rpm -qf /path/application_name Display the rpm that contains application application_name
  basic linux commands

Starting and Stoping 

startx Start the X system
shutdown -h now Shutdown the system now and do not reboot
halt
Same as above
shutdown -r now Reboot
reboot Same as above
shutdown -r +10 Reboot in 10 minutes
   basic linux commands

Mounting filesystems

mount -t vfat /dev/sd(a)(1) /mnt/c_drive Mount the first partition 1 of the first hard disk drive a which is in fat32 vfat dormat under /mnt/c_drive directory
mount -t iso9660 /dev/cdrom /mnt/cdrom Mount cdrom under /mnt/cdrom directory
umount /mnt/hda1 Unmout the above
  basic linux commands

User administration

users Display users currently logged in
adduser username Create a new user called username
passwd username Define password for user called username
who List logged-in users
whoami Display current user
finger username Displays info about user username
su Log in as root from current login
su - Log in as root from current login and take root's path
exit Exit from console login (ie, logout).
 basic linux commands

Processes 

command Execute command in the foreground
command & Execute command in the background
ctrl+z Suspend a program
ctrl+c Interrupt a program
ps List all processes
kill -9 pid Kill process with id pid
top Monitor processes in real time
 basic linux commands

Networking 

hostname List the system's hostname
ifconfig Set/Display network information
host ip Resolves ip's hostname
ping ip/hostname Check if ip/hostname is reachable
traceroute ip/hostname Find network path to ip/hostname
  
 basic linux commands

System Information

uname -a General system information
fdisk -l List partition tables
cp filename /path/dir_name Copy filename into directory /path/dir_name
df -T -h List filesystem disk space usage
lspci List PCI devices
lsusb List USB devices
free -m Display RAM+Swap usage

 basic linux commands

Program Compile

gcc -o output file.c Compile a C program
./output Run a C program you have compiled
g++ -o output file.cpp Compile a C++ program
./output Run a C++ program you have compiled
./configure && make && su -c 'make install' Configure, compile and install a program with Makefile