55
Basic LINUX commands that a DBA should know groupadd This is the command used to create new group. At OS level group is used to give and take pivillages. Syntax : groupadd <group name> Ex : [root@rac5 ~]# groupadd group1 View : [root@rac5 ~]# cat /etc/group -This command used to view which user belongs to which group. Output: group1:x:607: useradd This is the command used to create a new user in a group. Syntax : useradd -g <group name> <user name> Ex : [root@rac5 ~]# useradd -g group1 user1 passwd This is the command used to give password for create use or to update the password. Syntax : passwd <user name> Ex: [root@rac5 ~]# passwd user1 Output : [root@rac5 ~]# Changing password for user soufir. New UNIX password: BAD PASSWORD: it is based on a dictionary word Retype new UNIX password: passwd: all authentication tokens updated successfully. date

Basic LINUX Commands That a DBA Should Know Oracle Database Experience

Embed Size (px)

DESCRIPTION

LINUX Command

Citation preview

Basic LINUX commands that a DBA should knowgroupadd This is the command used to create new group. At OS leel group is usedto gie and takepiillages.Syntax : groupadd Ex : [root@rac5 ~]# groupadd group1View: !root@rac5 ~]# cat /etc/group "This commandusedtoiew which user #elongs to which group.Output: group1:x:607:useradd This is the command used to create a new user in a group.Syntax : useradd -g Ex : [root@rac5 ~]# useradd -g group1 user1passwdThis is the command used to gie password $or create use or to updatethe password.Syntax : passwd Ex: [root@rac5 ~]# passwd user1Output :[root@rac5 ~]# !ang"ng password #or user sou#"r$%ew &%'( password:)*+ ,*--./0+: "t "s 1ased on a d"ct"onar2 word0et2pe new &%'( password:passwd: a33 aut!ent"cat"on to4ens updated success#u332$datea. This is the command used to iew the current s%stem date.Syntax : dateOutput : .ed /ct 57 51:55:66 '-7 5010#. In order to update the date we can gie &Syntax : [root@rac5 ~]# date -s 85 /7 5010 19:00:008O'[root@rac5 ~]# date --set:857 /7 5010 51:56:008Output : -at /ct5 19:00:00 '-7 5010ca3This command shows the calender o$ current %ear or an%.Ex : [root@rac5 ~]#a3Output : [root@rac5 ~]#/cto1er 5010-u ;o 7u .e 7! 10 11 15 16 19 15 1617 1= 1> 50 51 55 5659 55 56 57 5= 5> 6061pwd This command is to iew the present working director%.Ex : [root@rac5 ~]# pwdOutput : [root@rac5 ~]# /root$cda.This is the command used to change a director%Ex : [orac3e@rac5 ~]? 3saut!or"@edA4e2s#"3e #"3e5ora'nBentor2stand$oraaut!or"@ed-4e2s#"3e1#"3e6sou#"r[orac3e@rac5 ~]? cd sou#"r[orac3e@rac5 sou#"r]?#.This is used to go #ack to parent director%Ex : cd ..m4d"rThis command is used $or make a new director%. Ex : m4d"r d"r1rmd"rThis commad is used $or remoe a director%. Ex : rmd"r d"r1rm -r#This command is used to $orce$ull% remoe a direcor%.Ex : rm -#r d"r1manThis command is used to showthe online manual pages o$ relatedcommandsEx : man 3s3sThis command is used to list all contents o$ directoriesEx : 3s3s -3tThis command is used to list lot o$ in$ormation a#out contents o$directoriesEx : 3s -3tThe permissions are the $irst () characters o$ the line *"rw+rw+""", andcan #e #roken down as $ollows.- rwx r-- r-- 1 root root 765 Apr 23File type Owner Group All Links Owner Group Size Mod dtetouc!This command is used create an empt% $ile Ex : touc! #"3e1catThis command is used to create and iew $iles o$ directoriesEx : cat #"3e1cat #"3e1 > new#"3e// owerwrite newfle with fle1cat #"3e1 >> new#"3e // appendnewflethecontentswithfle1cpThis command is used to cop% a $ile $rom one to another Ex : cp #"3e1 #"3enew mBThis command is used to rename the name o$ a $ile to otherEx : mB #"3e1 #"3enewsuThis command is used to switch one user to other. it doesnot change thecurrent working director%. so %ou cant access the -usr-s#indirectories.Ex : su sou#"rsu -This command is used to switch one user with changing current workingdirector%.Ex : su - sou#"r50 Most Frequently Used UNIX / Linux o!!ands "#ith $xa!ples%by &'M$()N'*'&'+'N on N,-$M.$& /0 1010This article provides practical examples for 50 most frequently used commands in Linux / UNIX.This is not a comprehensive list y any means! ut this should "ive you a #umpstart on some of the common Linux commands. $oo%mar% this article for your future reference.&id I miss any frequently used Linux commands' Leave a comment and let me %no(.). tar command examples*reate a ne( tar archive.2 tar c34 archi3e5na!e6tar dirna!e/+xtract from an existin" tar archive.2 tar x34 archi3e5na!e6tar,ie( an existin" tar archive.2 tar t34 archi3e5na!e6tar-ore tar examples. The Ultimate Tar *ommand Tutorial (ith )0 /ractical +xamples0. "rep command examples1earch for a "iven strin" in a file 2case in3sensitive search4.2 7rep 8i 9the9 de!o5fle/rint the matched line! alon" (ith the 5 lines after it.2 7rep 8' : 8i 9exa!ple9 de!o5text1earch for a "iven strin" in all files recursively2 7rep 8r 9ra!esh9 ;-ore "rep examples. 6et a 6rip on the 6rep7 8 )5 /ractical 6rep *ommand +xamples5. find command examples9ind files usin" file3name 2 case in3sensitve find4< fnd 8ina!e 9My=ro7ra!6c9+xecute commands on files found y the find command2 fnd 8ina!e 9My=ro7ra!6c9 8exec !d5su! >? @A9ind all empty files in home directory< fnd B 8e!pty-ore find examples. -ommy! I found it7 : )5 /ractical Linux 9ind *ommand +xamples;. ssh command examplesLo"in to remote hostssh 8l Cs!ith re!otehost6exa!ple6co!&eu" ssh clientssh 83 8l Cs!ith re!otehost6exa!ple6co!&isplay ssh client version2 ssh 8-,pen(()5:6Dp10 ,pen((L 06D6Ea FeF 1D 100:-ore ssh examples. 5 $asic Linux 11< *lient *ommands5. sed command examples=hen you copy a &>1 file to Unix! you could find ?r?n in the end of each line. This example converts the &>1 file format to Unix file format usin" sed command.2sed Gs/62//G flena!e/rint file content in reverse order2 sed 8n G1HIAhA2pG the7eeJstuK6txt@dd line numer for all non3empty3lines in a file2 sed G/6/LG the7eeJstuK6txt M sed GNA s/@n/ /G-ore sed examples. @dvanced 1ed 1ustitution +xamplesA. a(% command examplesBemove duplicate lines usin" a(%2 awJ GH"20 in array% > arrayN20OA print ?G te!p/rint all lines from /etc/pass(d that has the same uid and "id2awJ 8F GPG G2:LL2QG passwd6txt/rint only specific field from a file.2 awJ G>print 21025A?G e!ployee6txt-ore a(% examples. C /o(erful @(% $uilt3in ,ariales 8 91! >91! B1! >B1! NB! N9! 9IL+N@-+! 9NBD. vim command examples6o to the );5rd line of file2 3i! R1Q: flena!e6txt6o to the first match of the specified2 3i! R/search8ter! flena!e6txt>pen the file in read only mode.2 3i! 8& /etc/passwd-ore vim examples. ne Terminal;5. less command examplesless is very efficient (hile vie(in" hu"e lo" files! as it doesnNt need to load the full file (hile openin".2 less hu7e8lo78fle6lo7>ne you open a file usin" less command! follo(in" t(o %eys are very helpful.*&LRF W 4orward one window*&LR. W FacJward one window-ore less examples. Unix Less *ommand. )0 Tips for +ffective Navi"ation;;. su command examples1(itch to a different user account usin" su command. 1uper user can s(itch to any other user (ithout enterin" their pass(ord.2 su 8 U($&N'M$+xecute a sin"le command from a different account name. In the follo(in" example! #ohn can execute the ls command as ra#username. >nce the command is executed! it (ill come ac% to #ohnNs account.NCohnZde38ser3erO2 su 8 raC 8c GlsGNCohnZde38ser3erO2Lo"in to a specified user account! and execute the specified shell instead of the default shell.2 su 8s G()$LLN'M$G U($&N'M$;5. mysql command examplesmysql is proaly the most (idely used open source dataase on Linux. +ven if you donNt run a mysql dataase on your server! you mi"ht end3up usin" the mysql command 2 client 4 to connect to a mysql dataase runnin" on the remote server.To connect to a remote mysql dataase. This (ill prompt for a pass(ord.2 !ysql 8u root 8p 8h 1D161Y/6161To connect to a local mysql dataase.2 !ysql 8u root 8pIf you (ant to specify the mysql root pass(ord in the command line itself! enter it immediately after 3p 2(ithout any space4.;A. yum command examplesTo install apache usin" yum.2 yu! install httpdTo up"rade apache usin" yum.2 yu! update httpdTo uninstall/remove apache usin" yum.2 yu! re!o3e httpd;D. rpm command examplesTo install apache usin" rpm.< rp! 8i3h httpd81616:81160616el56i:/Y6rp!To up"rade apache usin" rpm.< rp! 8u3h httpd81616:81160616el56i:/Y6rp!To uninstall/remove apache usin" rpm.< rp! 8e3 httpd-ore rpm examples. B/- *ommand. )5 +xamples to Install! Uninstall! Up"rade! Ouery B/- /ac%a"es;C. pin" command examples/in" a remote host y sendin" only 5 pac%ets.2 pin7 8c 5 7!ail6co!-ore pin" examples. /in" Tutorial. )5 +ffective /in" *ommand +xamples;E. date command examples1et the system date.< date 8s 901/:1/1010 1:P5DP5:9>nce youNve chan"ed the system date! you should syncroniFe the hard(are cloc% (ith the system date as sho(n elo(.< hwclocJ Wsystohc< hwclocJ 88systohc Wutc50. ("et command examplesThe quic% and effective method to do(nload soft(are! music! video from internet is usin" ("et command.2 w7et httpP//prdownloads6source4or7e6net/source4or7e/na7ios/na7ios8:61616tar67V&o(nload and store it (ith a different name.2 w7et 8, ta7list6Vip httpP//www63i!6or7/scripts/download5script6php\src5idLEE01