0% found this document useful (0 votes)
16 views

Day2 Linux

1. Managing files and directories involves navigating between directories using commands like pwd, cd, and ls to list files. Common operations include creating and removing files/directories using commands like touch, mkdir, rm, and rmdir. Files can be copied, moved, and renamed using cp, mv. 2. Managing users and groups involves creating and modifying user accounts stored in /etc/passwd and passwords stored in /etc/shadow. Users can be assigned primary groups, home directories, and default shells. Groups are defined in /etc/group. Common commands are useradd, usermod, passwd, su, and userdel to manage users, and groupadd and groupdel to manage groups. 3

Uploaded by

abdelmonem
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Day2 Linux

1. Managing files and directories involves navigating between directories using commands like pwd, cd, and ls to list files. Common operations include creating and removing files/directories using commands like touch, mkdir, rm, and rmdir. Files can be copied, moved, and renamed using cp, mv. 2. Managing users and groups involves creating and modifying user accounts stored in /etc/passwd and passwords stored in /etc/shadow. Users can be assigned primary groups, home directories, and default shells. Groups are defined in /etc/group. Common commands are useradd, usermod, passwd, su, and userdel to manage users, and groupadd and groupdel to manage groups. 3

Uploaded by

abdelmonem
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#####Managing files and directories :-

1- Navigation pwd cd
51 pwd (Print work directory)
53 cd /home
67 cd ..
68 pwd
69 cd /home/hany/Desktop/
70 cd ../../..
72 cd /home/
73 cd /etc
74 pwd
75 cd -
76 cd /etc/security/
77 cd ~ <<<<<<<<< telda = home directory
---------------------------------------------------------------------------
2- listing files and directories
ls -l
sales1 sales others report1
rwx rw- r--
sales2 sales
sales3 sales
hr1 hr
it1 it
sysadmin it,sales,hr perm ?? rw-

- rw-r--r--. 1 root root 1.5K Dec 25 15:35 initial-setup-ks.cfg


file permissions owner group size time fileName
------------------------------------------------
ls -l -a -h -R
-------------------------------------------------
- file d directory l link
------------------------------------------------------------------------------
3- creating files and directories
touch fileName
mkdir directoryName
mkdir -p /d1/d2/d3 (P(Criat Parant) to criat the bath)
L -lr (r recursiv)
--------------------------------------------------------------------------------
4- removing files and directories
rm fileName
rm -r fileOrDirectoryName
rm -f fileName <<<<<<<force remove
rmdir EmptyDirectoryName
---------------------------------------------------------------------------------
5- copy files and directories
cp source target
cp file1 /home <<<< copy
cp file1 /home/file2 <<<< copy and rename
cp -r fileOrDirectoryName /home
----------------------------------------------------------------------------------
6- move files and directories
mv source target diff. move
mv /root/file1 /home/ <<<<<<<< move
mv /root/file1 /home/file2 <<<<<<<< move and rename
7- rename files and directories
mv /root/file1 /root/file2 <<<<<< rename
mv file1 file2
mv source target same rename
-----------------------------------------------
###################################################################################
##
2- managing Local users and groups :
user account
-user name
-password
-user ID root 0 user1000 1-999 reserved local system accounts
(Deamons) upto
-home directory (user login Environment) user profile /home/username
-primary Group (default sales1 sales1 group)
-default Shell default bash

/etc configuration files


/etc/passwd store users properties
/etc/shadow store users passwords
/etc/group store groups properties

-listing users:
gedit /etc/passwd
root:x:0:0:root:/root:/bin/bash
hany:x:1000:1000:hany:/home/hany:/bin/bash
username:x:UID:GID:comment:HomeDirectory:DefaultShell

id username (to check uoser ID)

--------------------------------------
create user
useradd ahmed
useradd -s /bin/sh -u 1005 -c "sales manager" khaled (-s Shell, -u User ID, -c
Comment)
useradd username
--------------------------------------
modify user
usermod
[root@Server1 ~]# gedit /etc/passwd
[root@Server1 ~]# usermod -s /bin/bash khaled
[root@Server1 ~]# usermod -c "Hr Manager" khaled
[root@Server1 ~]# usermod -u 1006 khaled
[root@Server1 ~]# usermod -l k.mostafa khaled (-l login name)
[root@Server1 ~]# id khaled
--------------------------------------
criat Password:
passwd userNameuser
---------------------------------------
swich user
su akhater
-------------------------------------------

remove ususerer
[root@Server1 ~]# userdel ahmed
[root@Server1 ~]# userdel -r k.mostafa (-r deleted every thing)
---------------------------------------------------------------------
group administration
user member of 1 primary group , secondry groups ....
sales1 sales,stuff,all
sales2 sales
it1 stuff,sales
rwx rwx r--
sales1 sales others
it1 stuff
----------------------------------------------------------------------

- create group
groupadd sales
-----------------------------
- modify group members
change primary group for user
#usermod -g primaryGroupName userName (-g to change primary group)
change secondry group for user
#usermod -G SecondaryGroup Username (-G to repls secondary guop)
add user to another secondary group
#usermod -a -G SecondaryGroup Username (-a -G to add user to another
secondary group)
---------------------------------------------------------------
- remove group
#groupdel GroupName

You might also like