Red Hat Enterprise Linux Essentials

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

RED HAT ENTERPRISE LINUX ESSENTIALS

DISPLAY THE DATE AND TIME


- date
DISPLAY THE CALENDAR
- cal
cal 5 2007
HELP COMMANDS
- whatis <command>
whatis date
Note: whatis actually uses the database called whatis, update the database using the
command 'makewhatis'
- <command> --help
date --help
- man <chapter> <command>
man cal
man -k <keyword> (search a keyword present in man pages)
man 5 passwd
- info <command>
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 /<directory>/<subdirectory>
--> To an relative path
ex: cd <directory>
--> 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 *.<file extension>
--> 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 <filename> (create the empty files)
--> touch {one,two}.<file extension>
--> vi <file Name> ( view and edit the files)
--> vi .<file Name> ( create the hidden files)
--> cat > <file Name> ( create the new file)
REMOVING FILES
--> rm <file Name>
--> rm *.<file extension>
--> rm -i <file Name>

(interactive)

--> rm -r <file Name>

(recursive)

--> rm -f <file Name>

(force)

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

(interactive)

--> rm -r <dir Name>

(recursive)

--> rm -f <dir Name>

(force)

DETERMINING FILE CONTENT


-

file <filename>

VIEWING TEXT PAGE BY PAGE


-

less [options] [filename]


Space

(moves ahead one full screen)

(moves back one full screen)

Enter

(moves ahead one line)

(moves back one line)

(moves to the top of the line)

moves to the bottom of the line)

/text

(searches for text)

(quits)

(go to vim editor mode and returns)

Ex: less /etc/passwd

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 <username>
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 <groupname>
PERMISSIONS
- File and directories have permissions to determine users 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 <file/directory>
where R is recursive
Note: Only root can change a files owner
CHANGING GROUP OWNERSHIP
- chgrp[-R] groupname <file/directory>
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 <filename>
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 <filename>
or
chmod ugo+rwx <filename>
Full permission to user, read permission to group and read permission to others.
chmod u+rwx,g+r,o+r <filename>
Full permission for the user and the group, read permission for the others
chmod ug+rwx,0-wx <filename>

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 <filename>
Full permission to all

chmod 641 <filename>


Read and write permission to owner,
Read permission for the group,
Execute permission for others

You might also like