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

Sunday, January 13, 2008

How to list and view files in Linux

ls -> list/displays contents of a directory.

cat -> displays (concatenate) the contents of a text file to the screen.

head-> views first few lines of a file. The defaut number of lines is 10.

tail -> views the last few lines of a file.

more -> view the file page by page.

less -> view the file page by page but you can use the up-down keys.

grep -> global regular expression print, Displays lines in a text file mathcing a given regexp.

file -> determines the file type of a file.

How to identify the original file type of a file in Linux

In Linux most files do not have file extensions.
Using the File command you can determine what is the real filetype of a certain file.

type File [filename]

Filename is the identifier to a given file.
File extensions is the identifiers following a dot (.) at the end of filename.

How to change directories in Linux

cd -> change the directory
cd.. ->change directory one step backward
cd- ->change directory to previous working directory
pwd -> print working directory
cd~ -> change to user's home directory

How to verify the applied settings in Linux

To verify the settings or changes in the configuration, you can use the following commands

->ifconfig - to verify the IP address
->route -n to verify the default route
->netstat -nr to verify the default route
->cat /etc/resolv.conf to verify the DNS settings
->hostname to verify the computer hostname

How to apply the new settings in Linux

To apply the configuration that has been done, you must run the following:

For Redhat/Mandrake

#service network restart
or
#/etc/rc.d/init.d/network [startstoprestart]

For debian/Debian based Linux

#/etc/init.d/networking[startstoprestart]

For Hostname settings take effect, restart the whole operating system.

How to configure Nameserver for all Linux OS

Edit and save the file resolv.conf

Location: /etc/resolv.conf

Value:

nameserver 192.168.1.253
nameserver 192.168.1.252

How to configure Gateway and Hostname in Redhat and Mandrake

Edit and save the the file using linux editor

location: /etc/sysconfig/network

Value:

Networking=YES
Hostname=redhatenterprise
Gateway=192.168.0.254