Wednesday 28 December 2011

Redhat Enterprise Linux Essentials

DISPLAY THE DATE AND TIME
- date
DISPLAY THE CALENDAR
- cal
cal 5 2007
HELP COMMANDS
- whatis
whatis date
Note: whatis actually uses the database called whatis, update the database using the
command 'makewhatis'
- --help
date --help
- man
man cal
man -k (search a keyword present in man pages)
man 5 passwd
- info
info cal
CURRENT WORKING DIRECTORY
- pwd - print name of current/working directory
ABSOLUTEPATH
Begin with a forward slash, complete road map of file location.
vim /var/named/chroot/etc/named.conf
RELATIVE PATH
Do not begin with a slash, specify location relative to your
current working directory
cd var
cd named
CHANGING DIRECTORIES
--> To an absolute path
ex: cd //
--> To an relative path
ex: cd
--> To your home directory (anyuser including root)
cd
--> To a your previous working directory
cd -
--> To a your previous directory
cd ..
LISTING DIRECTORY CONTENTS
--> ls ( lists the contents of the current directory)
--> ls -a (include hidden file)
--> ls -l (or) ll (long listing)
--> ls /usr (display contents of the directory)
--> ls *.
--> ls -R (displays files including sub directories)
--> ls -ld (directory and symlink information)
COPY FILES AND DIRECTORIES
--> cp [options] file destination
--> cp [options] file1 file2 destination
--> cp -i (ask for overwriting a file)
--> cp -r (copy a directory and subdirectry)
MOVING AND RENAMING FILES AND DIRECTORIES
--> mv (move and rename directories,files)
--> mv [options] file destination
--> mv [options] file1 file2 destination
-f, --force
do not prompt before overwriting
-i, --interactive
prompt before overwrite
CREATING FILES
--> touch (create the empty files)
--> touch {one,two}.
--> vi ( view and edit the files)
--> vi . ( create the hidden files)
--> cat > ( create the new file)
REMOVING FILES
--> rm
--> rm *.
--> rm -i
--> rm -r
--> rm -f
(interactive)
(recursive)
(force)
CREATING DIRECTORY
--> mkdir

(creates the directories)
--> mkdir -p /
(creates the directory and sub directory)
REMOVING THE DIRECTORY
--> rmdir < Empty directory Name>
--> rm -i

--> rm -r

--> rm -f

DETERMINING FILE CONTENT
-
VIEWING TEXT PAGE BY PAGE
-
(interactive)
(recursive)
(force)
file
less [options] [filename]
Space
b
Enter
k
g
G
/text
q
v
Ex: less /etc/passwd
(moves ahead one full screen)
(moves back one full screen)
(moves ahead one line)
(moves back one line)
(moves to the top of the line)
moves to the bottom of the line)
(searches for text)
(quits)
(go to vim editor mode and returns)
USERS, GROUPS, AND PERMISSIONS
- Users and groups are used to control access to files.
- Every file is owned by a user and associated with group
- Every process has an owner and group affiliation.
USERS
- Every user is assigned a unique user ID number(uid)
- Users' names and uids are stored in /etc/passwd
- Users are assigned a home directory and a progam that is run when
they log in.(A shell is a program)
Ex: useradd
GROUPS
- Users are assigned to groups
- Each group is assigned a unique Group ID number(gid)
- gids are stored in /etc/groups
- Each user is given their own private group
- All users in a group can share files that belong to the group.
Ex: groupadd
PERMISSIONS
- File and directories have permissions to determine user’s access-levels.
- permissions are set to:
i)the owner of the file
ii) the group members
iii) all others
- permissions that are set are called read,write,and excute
PERMISSIONS TYPES
- Four symbols are used to when displaying permissions
r --> read the file or list a directory's contents
w --> write the file or create and remove files from directory
x --> permission to execute a program or change into a directory and do
a long listing of the directory
- --> no permissions.
Note: file permissions are viewed by "ls -l" and ll (long listing)
CHANGING FILE OWNERSHIP
- chown [-R] username
where R is recursive
Note: Only root can change a file’s owner
CHANGING GROUP OWNERSHIP
- chgrp[-R] groupname
Note: Only root or the owner can change a file's group
DEFAULT PERMISSIONS
Default permission for directories is 777 minus umask
Default permission for files is the directory default without execute permission.
umask is set with the umask command.
Non-privileged users' umask is 002
Files will have permissions of 664
Directories will have permissions of 775
root's umask is 022
CHANGING PERMISSIONS -SYMBOLIC METHOD
- chmod [-R] mode
mode:
u,g,o for user, group and other
+ or - for grant or deny
r,w or x for read write and execute
Ex:
Full permission to user, group and others
chmod u+rwx,g+rwx,o+rwx
or
chmod ugo+rwx
Full permission to user, read permission to group and read permission to others.
chmod u+rwx,g+r,o+r
Full permission for the user and the group, read permission for the others
chmod ug+rwx,0-wx
CHANGING PERMISSIONS - NUMERIC METHOD
- uses a three-digit mode number
First digit specifies owner's permissions
Second digit specifies group's permissions
Third digit specifies other's permissions
- permissions are calculated by adding
4 for read
2 for write
1 for execute
Ex: chmod 777
Full permission to all
chmod 641
Read and write permission to owner,
Read permission for the group,
Execute permission for others

No comments:

Post a Comment