Вы находитесь на странице: 1из 9

19/10/2016

ORACLEBASELinuxGroupsandUsers

Home(/)Articles(/articles)Linux(/articles/linux)
Here

LinuxGroupsandUsers
Thisarticleexplainshowtocreate,modifyand
removelocalgroupsandusersonLinux,with
specificreferencetotheinformationneededforthe
RHCSAEX200

(http://www.redhat.com/training/courses/ex200/examobjective)andRHCEEX300
(http://www.redhat.com/training/courses/ex300/examobjective)certificationexams.
Remember,theexamsarehandson,soitdoesn'tmatterwhichmethodyouusetoachievethe
result,solongastheendproductiscorrect.
Groups
Users
PasswordExpiry
UserManager
SwitchingUsers
ImportantFiles
LDAP
PasswordlessLogin

Groups
Groupsallowmultipleuserswithsimilarsecurityandaccesslevelstobelinked,making
managementofthoseuserseasier.Alocalgroupiscreatedwiththe groupadd command.
#groupadddba

Thegroupinformationisvisibleinthe"/etc/group"file.EachgrouphasaGID.Ifthisisnotassigned
explicitly,thenextlargestnumberisused.Wecanseegroupwejustdefinedhasbeenassignedthe
GIDof500.
#cat/etc/group|grepdba
dba:x:500:
#

IfyouhavethesamegroupsacrossmultipleserversitmakessensetosettheGIDexplicitlyto
makesureitisthesameacrossallservers.
#groupaddg1000dba
Traduzir
https://oraclebase.com/articles/linux/linuxgroupsandusers

1/9

19/10/2016

ORACLEBASELinuxGroupsandUsers

Existinggroupsaremodifiedusingthe groupmod command.


#groupmodg2000dba
#groupmodnnew_dbadba

Groupsaredeletedusingthe groupdel command.


#groupdelnew_dba

Users
The useradd commandcreatesnewlocalusers.
#useraddoracle

Theuserdetailsarevisibleinthe"/etc/passwd"file.IfnoUIDisspecified,thenextlargestUIDis
assigned.Anewgroupwithagroupnamematchingtheusernameisalsocreated.Bydefault,the
usershomedirectoryiscreatedunderthe"/home"directoryandtheshellis"/bin/bash".
#cat/etc/passwd|greporacle
oracle:x:500:500::/home/oracle:/bin/bash

#cat/etc/group|greporacle
oracle:x:500:
#

Aswithgroups,ifyouhavethesameuseracrossseveralserversitmakessensetoexplicitlydefine
aUIDsoitmatchesonallservers.Iftheusersshouldbeassignedtoanexistinggroup,thiscanbe
donewhilecreatingtheuseralso.
#groupaddg1000dba
#useraddGdbau2000tim_hall
#cat/etc/passwd|greptim_hall
tim_hall:x:2000:2000::/home/tim_hall:/bin/bash

#cat/etc/group|greptim_hall
dba:x:1000:tim_hall
tim_hall:x:2000:
#

Thereareflagstoalterthedefaultshell(s)anddefaulthomedirectory(d),butforthemostpart
theseshouldbeunnecessary.
Mostoftheuserdetailscanbemodifiedusingthe usermod command.
#usermods/bin/kshtim_hall
#usermodaGoinstalltim_hall

The passwd commandisusedtosetthepasswordforaspecifieduser,orthecurrentuserifno


usernameisspecified.

Traduzir

https://oraclebase.com/articles/linux/linuxgroupsandusers

2/9

19/10/2016

ORACLEBASELinuxGroupsandUsers

#passwdtim_hall
Changingpasswordforusertim_hall.
Newpassword:
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.

#passwd
Changingpasswordforuserroot.
Newpassword:
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
#

Theuserdelcommandremovesauser.The"f"optiondeletestheusereveniftheuseriscurrently
loggedin.The"r"flagremovestheuser'shomedirectory.
#userdelrtim_hall

Whenloggedinasthe"root"user,thecommandpromptwilldisplaya"#"symbol.Forordinary
users,the"$"symbolisdisplayed.

Passwordexpiry
Passwordexpiry(ageing)iscontrolledusingthe chage command.Tocheckthecurrentpassword
expiryinformationusethe"l"option.
#useraddtim_hall
#chageltim_hall
Lastpasswordchange

Passwordexpires

Passwordinactive

Accountexpires

Minimumnumberofdaysbetweenpasswordchange
Maximumnumberofdaysbetweenpasswordchange
Numberofdaysofwarningbeforepasswordexpires
#

:Mar01,2012
:never
:never
:never
:0
:99999
:7

Thereareanumberofoptionsavailable,butthemostcommonlyusedonesareshownbelow.
##Setthedaysbeforechangerequired(M)andthenumberofdayswarning(W)
#chageM30W5tim_hall

##Immediatesexpireapassword.
#chaged0tim_hall

Changesarevisibleusingthe"l"listoptionagain.

https://oraclebase.com/articles/linux/linuxgroupsandusers

3/9

19/10/2016

ORACLEBASELinuxGroupsandUsers

#chageltim_hall
Lastpasswordchange

Passwordexpires

Passwordinactive

Accountexpires

Minimumnumberofdaysbetweenpasswordchange
Maximumnumberofdaysbetweenpasswordchange
Numberofdaysofwarningbeforepasswordexpires
#

:passwordmustbechanged
:passwordmustbechanged
:passwordmustbechanged
:never
:0
:30
:5

UserManager
The"UserManager"dialogisaGUItooltomanageusersandgroups.Itcanbestartedfromthe
menu(System>Administraton>UsersandGroups)orbyrunningthe systemconfigusers
command.

Highlightingaspecificuserandclickingthe"Properties"buttonallowsyoutoamendtheuser
information,accountexpiration,passwordexpirationandgroupselection.

https://oraclebase.com/articles/linux/linuxgroupsandusers

4/9

19/10/2016

ORACLEBASELinuxGroupsandUsers

#lsal/etc/skeltotal36drwxrxrx.4rootroot4096Feb2514:11.drwxrxrx.113rootroot12288
Mar114:38..rwrr.1rootroot18Mar292011.bash_logoutrwrr.1rootroot176Mar29
2011.bash_profilerwrr.1rootroot124Mar292011.bashrcdrwxrxrx.2rootroot4096Nov
202010.gnome2drwxrxrx.4rootroot4096Feb2514:06.mozilla[root@rhce1oracle]#

SwitchingUsers
The su commandallowsyoutoswitchusers.Includingthe""optionmakestheshellaloginshell,
soyoualsogetthenewuser'sprofileinformationset.
#suoracle
#suoracle

Ifnouserisspecified,itisassumedyouaretryingtoswitchtothe"root"user.
$su
Password:
#

Usethe logout or exit commandtoreturnthetheoriginalshell.


The"c"optionallowsyoutopassasinglecommandtotheshelltobeexecuted.Thiscommand
couldalsobeasavedscript,orascriptdefinedinline.

https://oraclebase.com/articles/linux/linuxgroupsandusers

5/9

19/10/2016

ORACLEBASELinuxGroupsandUsers

#suoraclec"touch/tmp/test_file1.txt"
#lsal/tmp/test_file1.txt
rwrwr.1oracleoracle0Mar216:17/tmp/test_file1.txt
#

#suoraclec"echo'touch/tmp/test_file2.txt'>>/tmp/myscript.sh;chmodu+x/tmp/myscr
#lsal/tmp/myscript.sh
rwxrwr.1oracleoracle26Mar216:41/tmp/myscript.sh
#

#suoraclec/tmp/myscript.sh
#lsal/tmp/test_file2.txt
rwrwr.1oracleoracle0Mar216:42/tmp/test_file2.txt
#

ImportantFiles
The"/etc/profile"filecontainssystemwideenvironmentsettingsandrunsallthescriptsinthe
"/etc/profile.d"directory.Ifyouwanttomakeglobalchanges,itisbettertodefineanew
"/etc/profile.d/custom.sh"filecontainingthechanges,ratherthaneditingthe"/etc/profile"filedirectly.
Whenyoucreatenewuserwiththe useradd command,thefilesinthe"/etc/skel"directoryare
copiedintotheusershomedirectory.
#lsal/etc/skel
total36
drwxrxrx.4rootroot4096Feb2514:11.
drwxrxrx.113rootroot12288Mar114:38..
rwrr.1rootroot18Mar292011.bash_logout
rwrr.1rootroot176Mar292011.bash_profile
rwrr.1rootroot124Mar292011.bashrc
drwxrxrx.2rootroot4096Nov202010.gnome2
drwxrxrx.4rootroot4096Feb2514:06.mozilla
#

Ofthesefiles,probablythemostcommonlyusedisthe".bash_profile"file,typicallyforsetting
environmentvariables.
ORACLE_BASE=/u01/app/oracle;exportORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1;exportORACLE_HOME
ORACLE_SID=ORCL;exportORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH;exportPATH

The".bash_profile"filesourcesthe".bashrc"file,whichistypicallyusedforfunctionsandaliases,
althoughtheycanbeplacedinthe".bash_profile"fileifyouwish.
aliasrm='rmi'

https://oraclebase.com/articles/linux/linuxgroupsandusers

6/9

19/10/2016

ORACLEBASELinuxGroupsandUsers

Thefirstthingthe".bashrc"doesissourcethe"/etc/bashrc"file,whichcontainssystemwide
functionsandaliases.
It'sworthspendingalittletimelookingthroughthecontentsofthesefilestolookattheinter
dependencies,butmuchofthetimeIonlyeditthe".bash_profile"filesintheindividualuserhome
directories.

LDAP
CompaniesoftenholdgroupinformationandusercredentialsinacentralizedLDAPserver.Linux
canuseLDAP,ratherthanlocaluserandgroupinformaton.Makesurethenecessarypackagesare
installed.
#yuminstallopenldapclientsauthconfiggtk

The"AuthenticationConfiguration"dialogisavailablefromthemenu(System>Administration>
Authentication)orbyrunningthe systemconfigauthentication commandfromthecommand
line.

Changethe"UserAccountDatabase"settingto"LDAP".Thescreenwillaltertoallowtheentryof
LDAPserverinformation.

https://oraclebase.com/articles/linux/linuxgroupsandusers

7/9

19/10/2016

ORACLEBASELinuxGroupsandUsers

PasswordlessLogin
Ontheclient,issuethefollowingcommandandacceptallthedefaults.
sshkeygentrsa

Pushthepublickeyinthe"~/.ssh/id_rsa.pub"fileontheclienttothe"~/.ssh/authorized_key"fileon
theserver.
cat~/.ssh/id_rsa.pub|sshmy_user@myserver"cat>>.ssh/authorized_keys"

Makesurethepermissionsarecorrectontheserver.
sshmy_user@myserver"chmod700.ssh;chmod640.ssh/authorized_keys"

YouwillnowbeabletoSSHfromtheclienttotheserverwithoutapassword.
sshmy_user@myserver

Formoreinformationsee:
RHEL6Documentation(https://access.redhat.com/site/documentation/en
US/Red_Hat_Enterprise_Linux/)
Linuxmanpages(http://linux.die.net/man/)
RHCSAandRHCE(articleslinux#rhcsa_and_rhce)
Hopethishelps.RegardsTim...
BacktotheTop.
https://oraclebase.com/articles/linux/linuxgroupsandusers

8/9

19/10/2016

ORACLEBASELinuxGroupsandUsers

Plsql
Download PL/SQL Developer lots of features, plug-ins & more Go to
allroundautomations.com

0comments,read/addthem...(/misc/comments?page_id=1051)

Home(/)|Articles(/articles/articles)|Scripts(/dba/scripts)|Blog(/blog/)|Certification(/misc/ocp
certification)|Misc(/misc/miscellaneous)|About(/misc/siteinfo)
AboutTimHall(/misc/siteinfo#biog)
Copyright&Disclaimer(/misc/siteinfo#copyright)

https://oraclebase.com/articles/linux/linuxgroupsandusers

9/9

Вам также может понравиться