Pages

Wednesday, August 31, 2011

Find useful useful unix command

1. To find all the .conf file in / and copy it to /backup

# find . -name '*.conf' -print -exec cp '{}' ~/backup \;

No need to explain the options above except -print and exec.

-print - It is allways true and has a side effect of printing.

{} - This will replace the name of the file found.

\; - Means end of the line

---------------------------------------------------------------------------------------------------------

2. To find all the .txt files with odd characters( Contain upper and lowe case and numbers)

# find . -name '*.txt' -print0 | xargs -i -0 mv '{}' ~/backup

-print tell find to use null character insted of white space.

----------------------------------------------------------------------------------------------------------
3. To find all the files across the symbolic links

# find . -follow -name '*.txt' -print0 | xargs -i -0 mv '{}' ~/backup

-follow - This option help to find out the orgination of the symbolic links.

-----------------------------------------------------------------------------------------------------------

4. To find out all the.txt files case insensitively

# find . -follow -iname '*.txt' -print0 | xargs -i -0 mv '{}' ~/backup


------------------------------------------------------------------------------------------------------------

5. To find out file modified more than +90 days

# find . -name '*.txt' -mtime +90 -print


-mtime - Takes argument to specify the time frame.

--------------------------------------------------------------------------------------------------------------
6. To print out the files modified more than 7 days and less than 14 days


# find /home -mtime +7 -a -mtime -14 -print

---------------------------------------------------------------------------------------------------------------
7. To find the files with java extension

# find . -name '*java*' -print

----------------------------------------------------------------------------------------------------------------
8. To find the java files in all the directories in /

# find / -type d -name '*java*' -print

----------------------------------------------------------------------------------------------------------------
9. To find out all the block device files in /dev

# find /dev -type b -name '*' -print

----------------------------------------------------------------------------------------------------------------
10. To find out charecter special file in /dev

# find /dev -type c -name '*' -print

----------------------------------------------------------------------------------------------------------------
11. To find out all the directories in /

# find / -tyde d -name 'dev' -print

----------------------------------------------------------------------------------------------------------------
12. To find out the all the named pipes in dev directory

# find /dev -type p -name '*' -print

----------------------------------------------------------------------------------------------------------------
13. to find out all the symbolc link in /

# find / -type l -name '*' -print

----------------------------------------------------------------------------------------------------------------
14. To find all the files above 3MB

# find / +3000K -print

----------------------------------------------------------------------------------------------------------------
15. Finding Files By content

# grep -i vasanth /etc/passwd
(This can be used only when we have the vicinity of the file.)

----------------------------------------------------------------------------------------------------------------
16. To find the word vasanth from files inside /etc/

# find /etc -name '*' -exec grep -Hi vasanth '{}' \;

( Use of exec command:- When predicates are true upto that point it will execute the grep command for all the files.

'{}' is where the filename is put when executing the command
The \; indicates the end of the command
-H print if grep command find soomething

----------------------------------------------------------------------------------------------------------------



----------------------------------------------------------------------------------------------------------------
17. To find


Sunday, August 28, 2011

SIMPLE SHELL SCRIPT TO BACKUP WHOLE MYSQL DATABASES AND KEEP ONLY TWO LATEST COPIES

#! /bin/bash
# Written by Vasanth.T.M, L2-Systems Engineer(*nix), Perfomix, Inc.


CKUPDATE=$(date +%d-%m-%Y)
BACKUPDIR=/mysqlbackup
DATABASES=$(mysql -u root -h localhost -pmysql -Bse 'show databases')


delete_old ()
{
echo Deleting old backup of backup of "$name"
name="$1"
find "$BACKUPDIR" -name "$name-*.sql.bz2" | sort | head -n -2 | xargs --no-run-if-empty rm -f
}

back ()
{
for GH in $DATABASES; do
echo "Creating mysql backup of $GH"
mysqldump -u root -pmysql $GH | bzip2 --compress --stdout > $BACKUPDIR/$GH-$CKUPDATE.sql.bz2
name=`basename $GH`
delete_old "$name"
done
}
back

Wednesday, July 20, 2011

Controlling a Windows service From Linux

To list all services in remote windows box.

# net rpc service list -I IPADDRESS -U USERNAME%PASSWORD


To start/stop services in a remote windows box.

# net rpc service stop/start SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD

Sunday, June 26, 2011

RSYNC

1. # rsync -ae ssh server1:/home /home/backups/server1_home_backup/

This command will download all the files/Directories from the sever1 to local /home/backups/server1_home_backup

-a = archive mode. This will preserve permissions, timestamps, etc

-e = specify which remote shell to use. In our case, we want to use ssh which follow right after “e”

2. # rsync -zave ssh --progress server1:/home /home/backups/server1_home_backup/

-z = adds zip compression.

-v = verbose

–progress = my favorite parameter when I am doing rsync manually, not so good when you have it in cron. This show progress (how_many_files_left/how_many_files_total) and speed along with some other useful data.


3. rsync --delete-after -zave ssh --progress server1:/home /home/backups/server1_home_backup/


–delete-after = this will delete files on backup server which are missing from source after ALL syncing is done. If you don’t care of having extra files on your backup server and have plenty of disk space to spare, do not use this parameter.


4. rsync --delete-after -zave ssh --progress server1:/home /home/backups/server1_home_backup/ -n

The -n (or –dry-run) parameter is great to use for testing. It will not transfer or delete any files, rather will report to you what it would have done if it was ran with out -n parameter. This way you can test it with out destroying or transfering data just to find out that is not what you wanted.

Pring Number of Files Inside a Directory

1 .for i in `find -maxdepth 1 -type d`; do echo -n $i " ";find $i|wc -l; done


2. To list the Files inside /home directory.

# for i in `find /home/ -maxdepth 1 -type d`; do echo -n $i " ";find $i|wc -l; done

3.

#!/bin/bash
for i in `find $1 -maxdepth 1 -type d`; do
echo -n $i " ";
find $i|wc -l;
done

4. ls -lR | grep -B 1 -e “^total “

Wednesday, June 22, 2011

MYSQL-REPLICATION

MYSQL-REPLICATION
Binary login must be enabled on master server prior to replication.
2 process will execute on the each slave server to handle replication.
1 process execute on master server per-slave server
Replication is Asynchronous which means that changes are committed to one node and then it is
propagated to N number of slaves.
Ideal for non-updating application.
REPLICATION CONFIGURATION
Master Server: 192.168.1.100
Slave Server: 192.168.1.31
Slave username: replica
Slave Password: redhat
Put the following in your master my.cnf file under [mysqld] section:
# changes made to do master
server-id = 1
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
datadir = /var/lib/mysql/
log-bin = /var/lib/mysql/mysql-bin
# end master
Copy the following to slave’s my.cnf under [mysqld] section:
# changes made to do slave
server-id = 2
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
datadir = /var/lib/mysql/
# end slave setup
Create user on master:
mysql > grant replication slave on *.* to replica@'192.168.1.100'
identified by 'redhat';
Do a dump of data to move to slave:
mysqldump -u root --all-databases --single-transaction --master-
data=1 > masterdump.sql
import dump on slave:
mysql < masterdump.sql After dump is imported go in to mysql client by typing mysql. Let us tell the slave which master to connect to and what login/password to use: mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.100',
MASTER_USER='replica', MASTER_PASSWORD='redhat';
Let us start the slave:
mysql> start slave;
You can check the status of the slave by typing:
mysql> show slave status;

Tuesday, June 21, 2011

MYSQL COMMANDS

1. Port Used by mysql is - 3306

2. To check Mysql whether Mysql is start or stop - netstat -ntlp | grep 3306

3. To List the Database - > show databases;

4. To reveal currently logen users

> select users();

5. To list the command history

> select now ();

6. Terminal monitor mode of mysql

When we type mysql in the shell it enters in to the terminal monitor mode which means that we logged in to the database as user who is logged in to the shell.

7.  To login to the databases as a user

> mysql -u root -ppassworsd

8. Connecting from remote host.

> mysql -u user -ppassword -h remotehost


By default Mysql blocks the connection from remote host. We will get an error like given below.

ERROR 1130 (00000): Host 'virt1.example.internal' is not allowed to connect to this MySQL server

9. Tighten Privilages.


Default login credential table in mysql database permit root and anonymous login from the remote host. There are three way to secure user account

a. use 'mysqladmin' program

b. use mysql terminal monitor and set the privs.


# mysqladmin -u root -p password redhat


10. Securing boath root anonymous accounts.

Disabling anonymous access to the Database

There are two type users in mysql database

a. root

b. anonymous users

Any other user is anonymous user in the mysql database concept. In some Linux distributions anonymous users can also access the MYSQL database

To test this login to mysql database from unprivileged users shell and run the following command.

> select user();


the out shows

testuser@localhost

11 .Securing DB from anonymous access

# mysql -u root -p

> show databases;

>use mysql;

> show tables;

> select * from user;

or

> select user,host from user;

+-------+-------------------+
| user  | host              |
+-------+-------------------+
| root  | 127.0.0.1         |
| cacti | localhost         |
| root  | localhost         |
| root  | test1.example.com |
+-------+-------------------+
4 rows in set (0.05 sec)







  If you can see blank lines in the above table those accounts are anonymous accounts this where non-privileged Linux/Unix/Windows mysql substitution occurs. 


12. To view all the users with the corresponding password

> select user,host,password from user;

13. To Restrict all the anonymous access to the local host.

> set password for '@' localhost=password('abc123');


14. DELETING ANONYMOUS ACCOUNTS

> DELETE from user WHERE user = '.';

>  FLUSH PRIVILEGES;






NOTE: this command will reread the current table in mysql to determine who's is permitted to access the DBMS.


15 . Deleting the test DB from themysql

It is also suggested that you drop test database also because databases such as test act as connecting vector for malicious users.



16. USER CREATION


Senario:-

We want to create a user that user is permitted to login from any host.


> selcect user();

> show grants;

The output of the command is as follows.

+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)

*.* - This means that all databases and all tables


a. Creating Another Super user in mysql

> GRANT ALL PRIVILEGES ON *.* TO 'vasanth'@'%' WITH GRANT OPTION

Running the above command will create a new super user called vasanth.




> select currect_user();



+----------------+
| current_user() |
+----------------+
| vasanth@%      |
+----------------+

% - Means This user is allowded to connect from all hosts on the network.


> show grants;


B. To give permission to any user from any host

> GRANT ALL PRIVILEGES ON *.* TO ' '@'%' WITH GRANT OPTION;
> GRANT ALL PRIVILEGES ON *.* TO ' '@'%' WITH identified by 'password';


C. To drop a user run the below command

> use mysql;
> drop vasanth;


To check whether the user is deleted or not

>  select user,host,password from mysql.user;

d. To allow a user vasanth from remote machine

> grant all privileges on *.* to 'vasanth'@'192.168.1.24' identified by 'redhat';






17. PRIVILEGES SCOPES
-------------------------------------


It allow us to grant privileges to the local and remote users in the database.  

The general Hierarchy structure of DB is DB >> Tables >> Columns >> Routine levels



GLOBAL SCOPE LEVEL
----------------------------------

If you want to set privileges on the global scope level we need to interact with mysql.user which means that mysql being the database and user being the table.

To list the privilages in user table of mysql database

>use mysql;
>describe user;


DB SCOPE LEVEL ACCESS
--------------------------------------

If you want to set privileges on the DB SCOPE LEVEL we need to interact with mysql.host and mysql.db.

To list the privileges in host and db table

> use mysql;
> describe host;
>describe db;

GRANT PRVILAGES
---------------------------------


Task: Use grant command to create various users to create various privileges.


> GRANT ALL on  *.*  to  'hemanth'@'localhost' identified by 'redhat';

The above command create a user hemanth in local db with the password redhat and grant all the privileges on the all the databases.

To check whether the privilege is granted to use run the following.

> select user,host,password,Create_priv,Alter_priv  from mysql.user;

The newly created hemanth user has all privileges like root except GRANT PRIVILEGES to other users to check this run the following.

> show grants for  hemanth@localhost;

The output is
+-------------------------------------------------------------------------------------------------------------------------+
| Grants for hemanth@localhost                                                                                            |
+-------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'hemanth'@'localhost' IDENTIFIED BY PASSWORD '*84BB5DF4823DA319BBF86C99624479A198E6EEE9' |
+-------------------------------------------------------------------------------------------------------------------------+


There is no grant option


Again run the following


> show grants;

+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)

See the above output root to has the privilege to grant privilege to other hosts.

--------------------------


To create user called hemanth1 who can connect from any host do the steps;
> use mysql;
> GRANT ALL ON * to hemanth1 identified by 'redhat';

 Check the privileges granted to the user hemanth1

> select user,host,password,Create_priv,Alter_priv  from mysql.user;

The output is shown below.

+----------+----------------+-------------------------------------------+-------------+------------+
| user     | host           | password                                  | Create_priv | Alter_priv |
+----------+----------------+-------------------------------------------+-------------+------------
| hemanth1 | %              | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 | N           | N          |

If we use * wi9th grant command we didn't get the all privillages

To get all privileges to hemanth1 do the following

> use mysql;
>  GRANT ALL ON  *.*  to hemanth1 identified by 'redhat';
> select user,host,password,Create_priv,Alter_priv  from mysql.user;

Now hemanth1 will get  all the privillages.

--------------------------


To create a limited privileged user
as root run this.

> GRANT USAGE ON *.* to hemanth2 identified by 'redhat' ;

This user hemanth2 has no privs.

mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)


To grant test db access to the hemanth2 user-

> GRANT ALL ON test.* to hemanth2 identified by 'redhat';

--------------------------------------


REVOKE PRIVILEGES
-------------------------------














Monday, June 13, 2011

Install Mysql from source with partition enabled

Install Mysql from source with partition enabled
    ------------------------------------------------
   mysql-5.5.12.tar.gz

    1) cmake . -LH
    2) cmake .
    3) make && make install
    4) cd /usr/local/mysql/
    5) chown -R mysql .
    6) chgrp -R mysql .
    7) scripts/mysql_install_db --user=mysql
    8) ./bin/mysqld_safe  &


    rename /etc/my.cnf file
    disable default mysql daemon

Saturday, June 11, 2011

Openssh Reveled

 Openssh files and it's usage in LINUX
-----------------------------------------------------

1. /etc/init.d/sshd - Start script for the sshd on the system.

2. /etc/pam.d/ssh - PAM support for sshd.

3. /etc/ssh/ - This is the primary configuration directory for ssh server as well as server.

4 /etc/ssh/ssh_config - This is the primary configuration for ssh clients.

5. /etc/ssh/sshd_config - Global Configuration of ssh server.

6. /usr/bin/s  - Provide non interactivce copy between the servers.

7. /usr/bin/sftp - Provide secure file transfer protocol.

8. /usr/bin/slgin - Symlink to /usr/bin/ssh

9.  /usr/bin/ssh-agent - Provides the identity eg: Who you are, Stores private key for pki authentication. Run for each  X11 sessions and for other sessions. 

10. /usr/bin/ssh-add- Add identity  to the ssh-agent.

11. /usr/bin/ssh-copy-id - Copies identity to the remote system for PKI based logins.

12. /usr/bin/ssh-keyconverter - This convert RSA key protocol version1 key to protocol version2.

NOTE: All the cisco routers support SSH version 1 which is based on RSA version1.

13. /usr/sbin/ssh-keygen - Generates unique private key public key pairs. Thease are alos called identities. It support RSA1. RSA, DSA.

14. /usr/bin/ssh-keyscan - Scan network for ssh servers and stores key in ~/.ssh/known-hosts.





11.

Wednesday, May 25, 2011

MYSQL BUILDING FROM THE SCRATCH

                         MYSQL INSTALLATION
# Create mysql group and user with a particular gid and uid.
/usr/sbin/groupadd -g 525 mysql
/usr/sbin/useradd -u 525 -g 525 -s /bin/bash -d /opt/mysql mysql
# Download mysql source.
cd /opt/src
wget http://www.percona.com/mysql/community/mysql-5.1.42.tar.gz
# Copy source file to mysql home directory.
cp /opt/src/mysql-5.1.42.tar.gz /opt/mysql
/bin/chown -R mysql.mysql /opt/mysql
/bin/chmod 755 /opt/mysql
# Switch to mysql user.
su - mysql
cd /opt/mysql
# Extract the source file.
tar -zxvf /opt/mysql/mysql-5.1.42.tar.gz
cd mysql-5.1.42
# Configure mysql.
./configure --prefix=/usr/local/ --enable-thread-safe-client --with-
unix-socket-path=/var/tmp/unix.sock --with-tcp-port=3306 --with-
mysqld-user=mysql --with-openssl --with-innodb --with-docs --enable-
static --localstatedir=/var/mysql/data
# Make
/usr/bin/make
# Now as root user.
cd /opt/mysql/mysql-5.1.42
/usr/bin/make install
# Copy mysql configuration file to '/etc/my.cnf'.
cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
# Uncomment innodb lines in the conf file.
/bin/sed -ie 's/#innodb/innodb/g' /etc/my.cnf
/bin/chown mysql.mysql /etc/my.cnf
/bin/chmod 600 /etc/my.cnf
# Copy the startup script to /etc/init.d/mysqld.
cp /usr/local/share/mysql/mysql.server /etc/init.d/mysqld
/bin/chmod 744 /etc/init.d/mysqld
# Add the lib files path to /etc/ld.so.conf.
/bin/echo /usr/local/lib/mysql/ >> /etc/ld.so.conf
/sbin/ldconfig
/sbin/chkconfig --add mysqld
/sbin/chkconfig mysqld on
# Create the mysql data directory.
/bin/mkdir /var/mysql
/bin/chown -R mysql.mysql /var/mysql
# As mysql user create initial databases.
su - mysql
/usr/local/bin/mysql_install_db
# Now as root start mysql daemon.
/sbin/service mysqld start
# Set a password for root user if required.
/usr/local/bin/mysqladmin -u root password 'passpass'

Sunday, May 22, 2011

SOLARIS FILE SYSTEMS

1. To mount all the file system

# mountall

2. to unmount all the file system

# umnontall

3. To display the information about the file system that are currently mounted

# mount -v  (This infoemation is taken from /etc/mnttab)

4. To list the process that are accessing trhe system

# fuser -c

5.  Steps to unmount a file system

# umount /export/home

umount: /export/home busy

# fuser -c /export/home

/export/home: 9002o

# ps -ef | grep 9002

root 9002 8979 0 20:06:17 pts/1

0:00 cat
# fuser -c -k /export/home

/export/home: 9002o
[1]+ Killed  cat >/export/home/test

# umount /export/home





6.

Saturday, May 21, 2011

REMOVING ROOT PASSWORD OF MYSQL DB

Go to mysql prompt with

# mysql -u root

> use mysql;

>Select Host,  User, Password from User;


> update user set password = '' where user = 'root' and host = 'localhost';

Friday, May 20, 2011

CONFIGURING WU-FTPD DEAMON IN SOLARIS

1. To check port 21 id listening or not.
# netstat -anP tcp | grep 21

 *.21                 *.*                0      0 49152      0 LISTENThe Output like above means that it is lis-tening in all the ip address.

2. FTPD is running and it bind to its default port 21 in Solaris by default unless you make changes to the SMF configuration. SMF controls the service configuration for FTP in Solaris.

# svcs -a | grep ftp

online         Dec_20   svc:/network/ftp:default

This means that it is currently up and online.

3. To get more information on ftp
# svcs -l ftp

The ouput will be:

fmri         svc:/network/ftp:default
name         FTP server
enabled      true
state        online
next_state   none
state_time   Wed Dec 20 00:00:54 2006
restarter    svc:/network/inetd:default


4. To  list the FTP packages installed.

# pkginfo -x | grep -i ftp

SUNWftpr                          FTP Server, (Root)
SUNWftpu                          FTP Server, (Usr)
SUNWncft                          NcFTP - client application implementing FTP
SUNWtftp                          Trivial File Transfer Server
SUNWtftpr                         Trivial File Transfer Server (Root)

5. TO LIST ALL THE INFORMATION REGARDING THE PACKAGE SUNWftpu
 
 # pkginfo -l SUNWftpu

6. TO CHECK THE INCLUDED FILEs IN THE USER PACKAGE of wuftpd.

# pkgchk -l SUNWftpu | grep -i pathname

Pathname: /usr
Pathname: /usr/sbin
Pathname: /usr/sbin/ftpaddhost
Pathname: /usr/sbin/ftpconfig
Pathname: /usr/sbin/ftpcount
Pathname: /usr/sbin/ftprestart
Pathname: /usr/sbin/ftpshut
Pathname: /usr/sbin/ftpwho
Pathname: /usr/sbin/in.ftpd
Pathname: /usr/sbin/privatepw

ftpwho - gives the connected users and process information.
ftpcount - dump classes per count.
ftpconfig - Is used to configure anonymous as well as guest ftp.
in.ftpd - This is the main daemon runs in background and bind the port 21.
/etc/ftpd - Thsi directory houses the main configuration files.

6. SUNWftpr - This includes server side configuration files.

# pkgchk -l SUNWftpr | grep -i pathname

Pathname: /etc
Pathname: /etc/ftpd
Pathname: /etc/ftpd/ftpaccess
Pathname: /etc/ftpd/ftpconversions
Pathname: /etc/ftpd/ftpgroups
Pathname: /etc/ftpd/ftphosts
Pathname: /etc/ftpd/ftpservers
Pathname: /etc/ftpd/ftpusers
Pathname: /var
Pathname: /var/svc
Pathname: /var/svc/manifest
Pathname: /var/svc/manifest/network
Pathname: /var/svc/manifest/network/ftp.xml


7. SUNWftpr - Includes server side configuration files.
/etc/ftpd

ftpaccess - Primary configuration files for wu-ftpd.
ftphosts- This allow admins to define allow | deny access to certain hosts.
ftpservers- This allow admins to define virtual hosts.
ftpusers - users listed may not access via ftp.
ftpconversations- facilitates the support for tar gz and compress support.

8. Wu-Ftpd support both type of ftp connection.
1. PORT - Active FTP
In this type of connection client make TCP:21 server control connection.
When the client executes ls results in server initiating a connection back to client back usually TCP 20 (ftp-data)

2. PASSIVE - Passive FTP
In this type of connection client connect to the TCP \ port 21 at first. After that when execute a command called ls or any other command, server open a high port and instructing the client to source connection to the server. Then the client sources a connection to the high port on the server ( data connection).

NOTE: In passive FTP connection firewall is not necessary in corporate firewall because client is sourcing the connection.











SOLARIS QUOTAS

Quota supports 2 feature they are
1. Softlimit
2.Hardlimit

Softlimit is a warning stage.

When a user exceed softlimit system will log it in to the logs and begin a timer which last for 7 days.
Suppose our softlimit is 100mb and a user exceeds beyond the timer softlimit become hardlimit.


HardLimit

Hardlimit act as a storage sealing. A user can never exceed the hardlimit.  If the user meets the hard limit system will not allocate the storage space.

File system perspective of quotas
1. BLOCKS
2. INODES

Each file may be represented by each inode and datablocks. We can define the quota based on

Quota Tools

1. edquota
2. quotacheck -used to check consistencies against current usage.
3. quotaon - Enables quotas on file system.
4. repoquota -  Display quota information.


Steps to Enable Quota support
Modify /etc/vfstab to enable quota support per file system.
Modify the mount options  columns.


Create empty quotas file in /export/home/quotas && chmod 600 /export/home/quota
 # nano /etc/vfstab
/dev/dsk/c1d0s7 /dev/rdsk/c1d0s7        /export/home    ufs     2       yes     rq

#touch /export/home/quotas && chmod 600 /export/home/quotas

TO SETUP QUOTA FOR THE USER VASANTH USING FILE LIMIT


[root@solaris1 /]# edquota vasanth

fs /export/home blocks (soft = 5000, hard = 10000) inodes (soft = 0, hard = 0)

:wq
This will set quota for the user vasanth.
TO SETUP THE SAME QUOTA POLICY FOR THE ANOTHER USERS PLEASE DO THE STEPS.

# edquota -p user1 user2 user3 user4

TO CHECK THE SUPPORTED FILE SYSTEMS IN OUR LOCAL SYSTEM

# quotacheck -va
*** Checking quotas for /dev/rdsk/c1d0s7 (/export/home)

TO CHECK THE USAGE DETAILS OF PARTICULAR USER

# quota -v vasanth
Filesystem     usage  quota  limit    timeleft  files  quota  limit    timeleft
/export/home       0   5000  10000                  0      0      0


TO ENABLE QUOTA SUPPORT ON PARTICULAR SLICE.


# quotaon -v /dev/dsk/c1dos7

TO DISABLE QUOTA SUPPORT

# quotaoff -va
This will turn off quota for all the file system













Friday, May 13, 2011

SOLARIS DISK PARTITIONING

DISK TERMINOLOGY

Disk contain the following components.

1. Tracks
2. Cylinders
3.Sectors/Blocks


Tracks
-----------
Tracks are the concentric ring on the each paltter .

Cylinder
-----------
Groups of tracks

Sectors/Blocks
----------------

512 byte block. Which is the smallest unit represented in hardisk.


Partition with Solaris is AKA slices


To display the Slices with in the harddisk.

#df -h

X86 PCS are limited to 4 primary partitions. Normally x86are divided in to 3 primary and 1 extended.

NOTE:Solaris need one fdisk Partition for it's use.

If you want to add another harddrive disk1

1. Create fdisk partion for Solaris use

2. Then Create  Slices

NOTE: Solaris uses a VTOC(VOLUME TABLE OF CONTENT) to represent the various slices with long fdisk partition on the disk. On the Sparc  Solaris uses VTOC to represent al the slices.

SLICE RULES USING VTOC
---------------------------------

1, Slices may created using VTOC on X86
2. These 10 slicers are represented by 0 to 9.
3. Slices 2,8,9 are reserved. Slice 2 is reserverd for VTOC
NOTE: VTOC Represent the disk label and occupying slice2
4. Slices 0,1,3,6,7 are avilable for use.

Root file system is slice 0.

PRINT VROC/DISKLABEL USING

# prtvtoc /dev/dsk/c0t0d0s0

C0 - Controller Number ## 1st controller
t0- Identifier for the bus orientated controller SCASI/SATA ### For IDE hardisk t0 is not present.
d0 - Represents disk number.
s0- Slice0

VTOC information contain entair diskinformation.

FORAMAT UTILITY
------------------------

1. To open the format utility

# format

2. To list the disk attached to the system

format> disk

3. To select a disk

Enter the disk Number want to select and put enter.

4. To discribe the current disk

format> Current

The output of the above command is shown below.

Current Disk = c1d0

/pci@0,0/pci-ide@1f,2/ide@1/cmdk@0,0



5, In the format menu we can get help by pressing question mark or help

6. Inside format tool there is a utilty called format. To format the a selected disk use the following steps.

format> disk

select the disk you want to format

format > format


select partition setup in the format menu.

format> partition

The above partion command will list the avilabe slices.
Select the slice number from there.

partition> 5
Then it will prompt for


Enter partition id tag : put an enter there.
Enter partition permission: put an enter there
Enter new starting cyl: Enter here a new cyl starting


This will create a slice.


Format the slice using the the utility

# newfs /dev/rdsk/c0d0s6

# mount /dev/dsk/c0d0s6 /mnt




.






















































Tuesday, May 10, 2011

Changing hostname in solaris

Change the hostname in the following files:

/etc/nodename
/etc/hostname.*interface
/etc/inet/hosts
/etc/inet/ipnodes

and rename directory under /var/crash

# cd /var/crash
# mv oldname newname

then reboot the server.

Sunday, May 1, 2011

DEVICES IN SOLARIS

1. If the Solaris Fault Management system detects a problem with a device, mes-
sages about the problem can be displayed by using the following command

# fmdump

NOTE: Messages are also traditionally written to the console and to the /var/adm/messages file. If the Fault Management system takes a device offline, the message “(retired)” is displayed in the prtconf output.

2. To view the device information from shell run the following command

# prtconf

NOTE:  It also give the amount of system memory available in our system. 

3 . To display the driver being used for the corresponding devices

# prtconf -D

4. To view the more output

# prtconf -pv

NOTE: The advantage of prtconf is it can be run by any user.

####################################################

X86 based Systems
--------------------------------

In x86 based systems we can display the device information using


# /usr/X11/bin/scanpci

or

# /usr/X11/bin/scanpci  -v  ( It provide more verbose output )

####KERNEL MODULES IN SOLARIS #########################

The location of kernel modules in Solaris is as follows.

/kernel/drv (default location for most leaf-node drivers)
/kernel/misc
/usr/kernel/drv
/usr/kernel/misc
/platform/i86pc/kernel/drv
/platform/i86pc/kernel/misc

5.To check the Loaded Modules information
------------------------------------------------------------

# modinfo | grep driver name


6.To determine whether the kernel is running in 32 or 64 bit mode

# lsainfo -kv


7. To manually load a kernel module

# modload /kernel/drv/amd64/e1000g

# modinfo | grep  e1000g

8. To get more verbose driver module information

# strings /kernel/drv/amd64/e1000g | grep -i  ver

9.To check which drivers are bound to which devices

# cat  /etc/driver_aliases

NOTE: The file has the format of driver name followed by device name


















Saturday, April 30, 2011

SOLARIS NETWORKING

1.The NICS in the system are listed by the following command

# dladm show-dev

2. Information about links on the data-link layer is displayed by

# dladm show-link

3. You also add information to certain configurationfiles to create a persistent network configuration. The most common files are /etc/hostname.interface, where interface is the specific interface that is used on the system, and /etc/hosts.

4. To set IPADDRESS to in Solaris X86 do the following.

# ifconfig rtls0 plumb 192.168.0.20/24

5. To check the ipaddress

# ifconfig -a

6. To make the configuration persist across the reboot do the following.

# echo 192.168.0.20/24 > /etc/hostname.rtls0

Add the corresponding ipaddress and hostname to /etc/hosts

# nano /etc/hosts

192.168.0.20/24 solaris1

7. To add the defaultrouter to the system

# echo 192.168.0.1 > /etc/defaultrouter

8. To enable packet forwarding in Solaris

# svcadm enable ipv4-forwarding

9. To start Routing protocol

# svcadm enable route:default


10. Perform a reconfiguration reboot

# reboot –- -r

11, To check packet forwarding is enabled

# routeadm

12. To disable packet forwarding

# svcadm disable ipv4-forwarding

13. To perfom reconfiguration reboot

# reboot -- -r

14. To view the routing table.

# netstat -rn

15.  To add a purticular route

#  route -p add -net 10.0.5.0/24 -gateway 10.0.5.150/24

15. 

















ADDING A NEWUSER IN SOLARIS

Defult home directory of normal users in Solaris is /export/home/username

Before creating the user you should create a directory in /export/home/username . Add the user using the following command.


# useradd -d /export/home/user user

The following option can be used with the useradd command.


1. -u 1003—Specifies the UID
2. -g 102—Specifies the GID of the primary group
3. -d /export/home/sandy—Specifies the home directory
4. -s /bin/ksh—Specifies the login shell
5. -m—Creates the home directory specified by the -d option
6. -k /etc/skel—Specifies the location of skeleton files, such as .profile
7. username —Specifies the user name of the account
###############################################################################################

# useradd -u 1003 -g 102 -d /export/home/user -s /usr/bin/bash -c "Vasanth" -m -k /etc/skell

#################################################################################################

UID AND GID OF USERS IN SOLARIS

1. A UID for a regular user can be between 100 and 2147483647 (except for
60001, 60002, and 65534).

2. UIDs 0–99, 60001, 60002, and 65534 are reserved for use by the Solaris OS

NOTE: avoid using UIDs over 60000 because they are not compatible with some Solaris features.

DEFAULT USER GROUP IN SOLARIS
##############################

When a new user is created he will be assigned to a primary group called staff.

NOTE: GIDs are assigned from the unused integers between 100 and 60000.