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

CHANGING DBID FOR ORACLE DATABASE 11G

C:\Users\computer>sqlplus SQL*Plus: Release 11.1.0.7.0 - Production on Thu Sep 10 21:03:33 2013 Copyright (c) 1982, 2008, Oracle.  All rights reserved. Enter user-name: sys as sysdba Enter password: Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> select dbid from v$database;       DBID ---------- 2188161033 SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options C:\Users\computer>nid DBNEWID: Release 11.1.0.7.0 - Production on Thu Sep 10 21:04:44 2013 Copyright (c) 1982, 2007, Oracle.  All rights reserved. Keyword     Description                    (Default) ---------------------------------------------------- TARGET ...

Difference between AWR, ADDM and ASH reports

AWR: Automatic Workload Repository gathers, processes and maintains performance stats used for problem detection and self-tuning the databases. Different Components that uses AWR are: Automatic Database Diagnostic Monitor Undo Advisor SQL Tuning Advisor Segment Advisor Different types of AWR Reports for different purposes: For Single Instance Environment: @$ORACLE_HOME/rdbms/admin/awrrpt.sql For Oracle RAC Environment : @$ORACLE_HOME/rdbms/admin/awrgrpt.sql For a particular SQL Statement : @$ORACLE_HOME/rdbms/admin/awrsqrpt.sql For Comparing the reports : @$ORACLE_HOME/rdbms/admin/awrddrpt.sql ADDM: Automatic Database Diagnostic Monitoring Report analyzes the AWR data on a regular basis, to give you overview of the root cause of the problem which is affecting your database’s performance. It also provides suggestions or recommendations for rectifying any problem identified and lists the areas which are having no issues. ADDM recommends multiple solutions for the DBA to choose from which...