08 June 2014

Basic Linux Commands for a DBA

Find the commands below, few more editing to come with time, until then use them.

1. ls -l
For listing the files as well as directories those are kept in the particular working directory.
Syntax: [root@info root]#ls -l

2. ls -la
Shows the hidden files.
Syntax: [root@info root]#ls -la

3. ls -li
Shows us the inode number of each and every file.
An inode stores all the information about a regular file, directory except its data and name.
Syntax: [root@info root]#ls -li

4. ls
Using this command we can see only file name nothing else.
Syntax: [root@info root]#ls

5. clear
It will clear the screen(short cut ctl+l).
Syntax: [root@info root]#clear

6. exit
To end a current session as well current terminal logging.
Syntax : [root@info root]#exit

7. touch
To create a new empty file.
Syntax : [root@info root]#touch

8. cd
To change the present working directory.
Syntax : [root@info root]#cd /home/share

9. cat
To view the contents of a file and it is also used for creating a new file with some contents.
Syntax : [root@info root]#cat

10. mkdir
To make a new directory.
Syntax : [root@info root]#mkdir newdirname

11. rm
To remove an empty file.
Syntax : [root@info root]#rm filename


12. rmdir
To remove a empty directory.
Syntax : [root@info root]#rmdir directoryname

13. rm [-i/-r/-f]
To remove a directory with its subdirectories as well as its files that is to remove a directory which already contains some files in it.
Syntax : [root@info root]#rm -i directory/filename
-i stands for interactively
-r stands for recursively
-f stands for forcefully

14. cp
To copy something in a destination file or directory.
Syntax : [root@info root]#cp sourcepath destinationpath

15. mv
To move one file or directory from one place to another place, it is also used for renaming adirectory or file.
Syntax : [root@info root]#mv
[root@info root]#mv oldfilename newfilename [to change the file name]

16. man
To view the manual page of commands for syntax.
Syntax : [root@info root]#man

17. info
To view the information about any command.
Syntax : [root@info root]#cat info
Shows information about cat command.

18. --help
To view the help documents of a command.
Syntax : [root@info root]#command name --help

19. dir
To view the subdirectories and files under the directory.
Syntax : [root@info root]#dir

20. su
To become a super user.
Syntax : [mango@info mango]$su -

21. who
Shows the user name and their ip addresses who have loged in on your server.
Syntax : [root@info root]#who

22. whoami
Shows your current logged in terminal user name.
Syntax : [root@info root]#whoami

23. who am i
This command shows you the logged in terminal number and user name and more detailed information.
Syntax : [root@info root]#who am I

24. pwd
To view the present working directory.
Syntax : [root@info root]#pwd

25. rpm
-ivh to intall a rpm package.
Syntax : [root@info root]#rpm -ivh packagename.rpm
rpm stands for 'red hat package manager'
-i stands for install
-v stands for verbose mode
-h stands for with hash sign(#)

26. rpm -q
To query about any rpm package.
Syntax : [root@info root]#rpm -q

27. pm -e
To uninstall an rpm package.
Synatx : [root@info root]#rpm -e package

28. find / -name
To find any file or directory in linux file system.
Syntax : [root@info root]#find / -name

29. su username
To switch from one user to another users home directory.
Syntax : [root@info root]#su oracle

30. su - username
To switch from one user to another user users home directory directly.
Syntax : [root@info root]#su – oracle

31. useradd
To create a new user.
Synatx : [root@info root]#useradd

32. passwd
To give a password of a user.
Syntax : [root@info root]#passwd

33. userdel
To remove a user from Linux.
Syntax : [root@info root]#userdel

34. groupadd
To add a new group.
Syntax : [root@info root]#groupadd

35. gruopdel
To delete a group.
Syntax : [root@info root]#groupdel

36. chown
To change the ownership of a file or directory.
Syntax : [root@info root]#chown

37. chgrp
To change the group ownership of a file or directory.
Syntax : [root@nettec root]#chgrp

38. chmod
To change the permission of a file or directory.
drwxrw-rw- 2 root root 4096 Mar 21 1:13 kkk
(permission) (ownr) (grpownr) (size) (name) IN
OCTAL VALUE
d stands for directory READ=4
r stands for read only permission WRITE=2
w stands for write only permission EXECUTE=1
x stands for execute only permission

Syntax : [root@nettec root]#chmod value fileordirectoryname

Update:
ls -1| wc -l
This command will display the count of files in the current directory.



rm -rf `ls -lt | grep 'Dec 21' | awk '{print $9}'`
remove files in the current directory matching the date

find /dbdrlarc/oradata/savdrlpr/archive/*.arc -mtime +2 -exec rm {} \;
remove the files in the above directory and ending with arc extension and files older than 2 days.


CourtesyInformation Center

No comments:

Post a Comment