Skip to main content

USEFUL LINUX COMMANDS


1. Display the number of CPUs      
   cat /proc/cpuinfo|grep processor|wc –l

2. Show top CPU%                  
    ps aux|sort -n +2

3. Display top-10 CPU consumers    
   ps aux|sort -rn +2|head -10

4. Shutdown server as root       
     /sbin/shutdown -r now

5. Kill all xxx processes        
     pkill [-9] “xxx”

6. Show swap paging space        
     /sbin/swapon -s

7. Show Linux syslog errors       
    tail /var/log/messages

8. See held memory segments       
    ipcs -m

9. Show Linux system parms          
  sysctl -a

10. Linux command history files     
   history|more

11. Huge pages
----------
grep -i huge /proc/meminfo

12. CPU INFO
------------
cat /proc/cpuinfo | grep processor | awk '{a++} END {print a}' 

13. ps -ef | grep tns ==> To get current running listeners in a server

14. Clear a file using /dev/null in Linux


$ cat /dev/null > file.txt - Example



15. $ du -h --max-depth=1 - To view size of files & folders in a DIR

Example:

oracle@/backup/data: du -h --max-depth=1 /backup
4.0K    /backup/oradba
154G    /backup/test
8.3G    /backup/datapump_api
4.0K    /backup/temp
91G     /backup/log

16. To Kill background running jobs

kill %1



http://unix.stackexchange.com/questions/104821/how-to-stop-a-background-process


17. du -h --max-depth=1 /oradata/Test > To get individual dir & file sizes in a folder




18. mkdir – make directories
Usage: mkdir [OPTION] DIRECTORY...
eg. mkdir prabhat

19. ls – list directory contents

Usage: ls [OPTION]... [FILE]...
eg. ls, ls l,
ls prabhat

20. cd – changes directories

Usage: cd [DIRECTORY]

eg. cd /Test

21. pwd print - name of current working directory

Usage: pwd

22. vim – Vi Improved, a programmers text editor

Usage: vim [OPTION] [file]...

eg. vim file1.txt

23. cp – copy files and directories

Usage: cp [OPTION]... SOURCE DEST
eg. cp sample.txt sample_copy.txt
cp sample_copy.txt target_dir

24. mv – move (rename) files
Usage: mv [OPTION]... SOURCE DEST
eg. mv source.txt target_dir

mv old.txt new.txt

25. rm - remove
files or directories
Usage: rm [OPTION]... FILE...
eg. rm file1.txt , rm rf some_dir

26. find – search for files in a directory hierarchy

Usage: find [OPTION] [path] [pattern]
eg. find file1.txt, find name file1.txt

27. history – prints recently used commands


Usage: history

28. cat – concatenate files and print on the standard output

Usage: cat [OPTION] [FILE]...
eg. cat file1.txt file2.txt
cat n file1.txt

29. echo – display a line of text

Usage: echo [OPTION] [string] ...

echo $HOME

30. grep print


lines matching a pattern

Usage: grep [OPTION] PATTERN [FILE]...
eg. grep i apple sample.txt

31. wc print


the number of newlines, words, and bytes in files

Usage: wc [OPTION]... [FILE]...
eg. wc file1.txt
wc L file1.txt

32. sort – sort lines of text files

Usage: sort [OPTION]... [FILE]...
eg. sort file1.txt
sort r file1.txt


33. chmod – change file access permissions

Usage: chmod [OPTION] [MODE] [FILE]
eg. chmod 744 calculate.sh

34. chown – change file owner and group

Usage: chown [OPTION]... OWNER[:[GROUP]] FILE...

eg. chown remo myfile.txt

35. su – change user ID or become superuser

Usage: su [OPTION] [LOGIN]
eg. su remo, su

36. passwd – update a user’s authentication tokens(s)

Usage: passwd [OPTION]
eg. passwd

37. who – show who is logged on

Usage: who [OPTION]
eg. who , who b, who q

38. ps – report a snapshot of the current processes

Usage: ps [OPTION]
eg. ps, ps el

39. kill – to kill a process(using signal mechanism)

Usage: kill [OPTION] pid
eg. kill 9 2275

40. tar – to archive a file

Usage: tar [OPTION] DEST SOURCE
eg. tar cvf /home/archive.tar /home/original
tar xvf /home/archive.tar

41. zip – package and compress (archive) files

Usage: zip [OPTION] DEST SOURSE
eg. zip original.zip original

42. unzip – list, test and extract compressed files in a ZIP archive

Usage: unzip filename

eg. unzip original.zip

43. scp – secure copy (remote file copy program)

“scp copies files between hosts on a network”
Usage: scp [options] [[user]@host1:file1] [[user]@host2:file2]

eg. scp file1.txt guest@10.105.11.20:~/Desktop/

44. fdisk – partition manipulator

eg. sudo fdisk l

45. mount – mount a file system

Usage: mount t
type device dir
eg. mount /dev/sda5 /media/target

46. umount – unmount file systems

Usage: umount [OPTIONS] dir | device...

eg. umount /media/target

47. du – estimate file space usage

Usage: du [OPTION]... [FILE]...
eg. du

48. df – report filesystem disk space usage

Usage: df [OPTION]... [FILE]...
eg. df

49. quota – display disk usage and limits

Usage: quota [OPTION]
eg. quota v

50. reboot – reboot the system

Usage: reboot [OPTION]
eg. reboot

51. poweroff – power off the system

Usage: poweroff [OPTION]

eg. poweroff

52. bg – make a foreground process to run in background

Usage: type 'ctrl+z' and then 'bg <job id>'

53. fg – to make background process as foreground process

Usage: fg [jobid]

54. jobs – displays the names and ids of background jobs


Usage: jobs

55. find - search for files in a directory hierarchy

Usage: find [OPTION] [path] [pattern]
eg. find name file1.txt

56. locate – find or locate a file
Usage: locate [OPTION]... FILE...

eg. locate file1.txt

57. vi editor - to create & edit files

ex. vi file.txt

58. view - To view a file in a read only mode

ex. view file.txt

59. $ ps -ef | grep pmon OR  ps -ef | grep smon 


To view the up and running databases in a server


60. lsnrctl - to connect to listener prompt

ex. LSNRCTL> stop, LSNRCTL> start, LSNRCTL> status

Comments

Popular posts from this blog

Registering The Database to RMAN catalog database:

Registering The Database to RMAN catalog database: Need to start RMAN as follows: RMAN target=sys/password@database_to_backup rcvcat=sys/password@recovery_catalog_database Another variation on the command, if the recovery catalog and the database were on the same server, might be as shown: oraenv ORACLE_SID = [KKUY] ? KKUY RMAN rcvcat=sys/password@recovery_catalog_database RMAN> connect target Recovery Manager: Release 8.0.5.1.0 - Production RMAN-06005: connected to target database: KKUY RMAN-06008: connected to recovery catalog database Use the below command to register the database. RMAN>register database; Want to verify if a database is registered in the recovery catalog. To do this, connect to RMAN and issue the command LIST INCARNATION OF DATABASE. RMAN> list incarnation of database; RMAN-03022: compiling command: list RMAN-06240: List of Database Incarnations RMAN-06241: DB Key Inc Key DB Name DB ID      CUR Reset SCN   Reset Time RMAN

ORA-39014: One or more workers have prematurely exited.ORA-00018: maximum number of sessions exceeded

ERROR: I was Performing a full database import and during the import I faced the below error. ORA-39014: One or more workers have prematurely exited. ORA-39029: worker 6 with process name "DW07" prematurely terminated ORA-31672: Worker process DW07 died unexpectedly. Job "SYSTEM"."SYS_IMPORT_FULL_04" stopped due to fatal error at 00:59:40 ORA-39014: One or more workers have prematurely exited. SOLUTION:  Run the import with fewer parallel processes, like PARALLEL=2 instead of 8. I was able to run the import successfully. NOTE 1: This errors occurs when there are less session allocation in the database. check the session,process parameters and increase them accordingly. To avoid such errors again. NOTE 2 : Note: Increasing processes parameter increases the amount of shared memory that needs to be reserved & the OS must be configured to support the larger amount of shared memory. So here we first need to increase the Memory & SG