https://oracle-base.com/articles/misc/unix-for-dbas
cd/directory name => takes you named directory
cd => takes you to user home directory
mkdir=>make directory
mkdir -p /u01/amin/dba => command to create recursive directory
ls => list command
root> ls -al
The "-a" flag lists hidden "." files. The "-l" flag lists file details.
ls-lrt => list command as per time
pwd => present working directory
The "rm" command is used to delete files and directories.
root> rm my.log
root> rm -R /archive
The "-R" flag tells the command to recurse through subdirectories.
The "mv" command is used to move or rename files and directories.
root> mv [from] [to]
root> mv my.log my1.log
root> mv * /archive
root> mv /archive/* .
The "." represents the current directory.
The "cp" command is used to copy files and directories.
root> cp [from] [to]
root> cp my.log my1.log
root> cp * /archive
root> cp /archive/* .
The "find" command can be used to find the location of specific files.
root> find / -name dbmspool.sql
root> find / -print | grep -i dbmspool.sql
The "/" flag represents the staring directory for the search. Wildcards such as "dbms*" can be used for the filename.
The "which" command can be used to find the location of an executable you are using.
oracle> which sqlplus
The "chmod" command is used to alter file permissions after the file has been created.
root> chmod 777 *.log
The "chown" command is used to reset the ownership of files after creation.
root> chown -R oinstall.dba *
The "-R" flag causes the command ro recurse through any subdirectories.
OS Users Management
See Linux Groups and Users.
The "useradd" command is used to add OS users.
root> useradd -G oinstall -g dba -d /usr/users/my_user -m -s /bin/ksh my_user
The "-G" flag specifies the primary group.
The "-g" flag specifies the secondary group.
The "-d" flag specifies the default directory.
The "-m" flag creates the default directory.
The "-s" flag specifies the default shell.
The "usermod" command is used to modify the user settings after a user has been created.
root> usermod -s /bin/csh my_user
The "userdel" command is used to delete existing users.
root> userdel -r my_user
The "-r" flag removes the default directory.
The "passwd" command is used to set, or reset, the users login password.
root> passwd my_user
Find Big Files
Find the top 20 biggest files recursively from this directory.
$ find . -type f -print0 | xargs -0 du -h | sort -hr | head -20
Find Big Files
Find the top 20 biggest files recursively from this directory.
$ find . -type f -print0 | xargs -0 du -h | sort -hr | head -20
Remove Old Files
The find command can be used to supply a list of files to the rm command or the "-delete" command can be used directly.
find /backup/logs/ -name daily_backup* -mtime +21 -exec rm -f {} ;
find /backup/logs/daily_backup* -mtime +5 -exec rm -f {} \;
find /backup/logs/daily_backup* -mtime +5 -delete;
Process Management
See Linux Process Management (ps, top, renice, kill).
The "ps" command lists current process information.
# ps
# ps -ef | grep -i ora
# ps -ef | grep -i ora | grep -v grep
# ps -ef | grep -i [o]ra
Specific processes can be killed by specifying the process id in the kill command.
# kill 12345
# kill -9 12345
You can kill multiple processes using a single command by combining "kill" with the "ps" and "awk" commands.
# kill -9 `ps -ef | grep ora | awk '{print $2}'`
:wq! to save contents of the file
:q! to discard last changes made
dd to delete single line
/hi to search Hi word inside the file
press i to get inside insert mode
press ESC key to exit out vi
cat is used to display contents of file
types of groups in Linux
Oinstall
dba
oracle
Primary group,Secoundry group
How to create a group in Linux
useradd -g oinstall -G dba -d /home/oracle oracle
connect to user
su - oracle, su - root
check present working directory
pwd
Assign password to the user
passwd oracle
how to check all the groups in linux
cat /etc/group
Permisions in Linux
how to check you have permission on particular path
su -root
ls -ld /u01
chmod 700 /u01
chmod 757/u01
replacing db name in vi editor
:%s/proddb/devdb/g
Manage memory in Linux
=====================
volatile Ram( Costlier)
non volatile -Hard disk
Useful Files
/etc/passwd User settings
/etc/group Group settings for users.
/etc/hosts Hostname lookup information
/etc/system Kernel parameters for Solaris.
/etc/sysctl.conf Kernel parameters for Linux.