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

Linux Basic Usage

The document summarizes Linux command line tools for managing users and groups such as useradd, usermod, userdel, passwd, and groupadd. It also provides overviews of the GNOME and KDE desktop environments, including their goals, features, and default configurations. Basic operations in Linux are explained like calendar, date/time, calculators, text editing with vi/gedit. Navigation in vi is outlined for lines, screens, words, paragraphs, and search.

Uploaded by

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

Linux Basic Usage

The document summarizes Linux command line tools for managing users and groups such as useradd, usermod, userdel, passwd, and groupadd. It also provides overviews of the GNOME and KDE desktop environments, including their goals, features, and default configurations. Basic operations in Linux are explained like calendar, date/time, calculators, text editing with vi/gedit. Navigation in vi is outlined for lines, screens, words, paragraphs, and search.

Uploaded by

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

Linux Basic Usage

User and password management & Logging into the system


Following are the Linux command line tools for managing users and groups :
 Useradd
useradd creates a new user or sets the default information for new users.
useradd is a low-level utility for adding users to a system. In general, the more
friendly adduser should be used instead.

useradd -D

When invoked without the -D option, the useradd command creates a new user
account using the values specified on the command line plus the default values from
the system.
 Usermod
Modifies a user account.
The usermod command is used by an administrator to change a user's system
account settings
usermod [options] LOGIN

Example
usermod -d /home/exampleusernew exampleuser

Modifies the home directory for the exampleuser account, changing it


to /home/exampleusernew.

 Userdel
The userdel command deletes a user account and all associated files.
The userdel command modifies the system account files, deleting all entries
that refer to the user name LOGIN. The named user must exist.
userdel syntax

userdel [options] LOGIN

Now lets set a password for this user. The 'passwd' command would be helpful in this case :
$ sudo passwd nixUser
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
 groupadd

1
Creates a new group.
The groupadd command creates a new groupaccount using the values specified
on the command line plus the default values from the system. The new group will
be entered into the system files as needed.
groupadd syntax

groupadd [options] group

 To add new user to the group


sudo adduser username groupname
 groupdel –delete the group
 groupmod - Modifies the group

GNOME & KDE


GNOME
 It is Short for GNU Network Object Model Environment
 It is one of the popular desktop environment used in Linux
 This Project started in 1996 and had evolved since then and the current version of GNOME is
GNOME 3.26 that came out in 2017
 It strives for simplification with finer details to essential features
 GNOME focuses on freedom, accessibility, internationalization and localization, developer
friendliness, organization, and support. It is supported by a large development community
that generally aim for six-month release schedules.
 GNOME positions a toolbar at the top and a pop-out dock featuring large application icons on the
left side of the screen that appears when the mouse hovers over its location. Its initial color
scheme emphasizes dark grey, orange, and purple.
 GNOME strives to utilize as few system resources as possible and offers a simple-to-use
interface that may be more friendly to novice Linux users.

KDE

 KDE is a desktop environment for a set of cross-platform applications designed to


run on Linux, Microsoft Windows, Solaris and Mac OS, designed by the KDE
Community.
 KDE focuses on configurability and an attractive graphical user interface. These goals
make it one of the most aesthetically pleasing and consistent.
 It has its desktop environment set up very similar to Windows and has a wide
variety of configuration options built in i.e has a lot of options
 The added customizability and Swiss-Army-knife approach also renders KDE a bit
more resource-intensive than GNOME

 KDE’s default settings keep things simple with one toolbar at the bottom of the
screen and a single main menu. Its initial color scheme favors blue and grey.

2
Basic Desktop Operations
OR
Explain basic general-purpose utility commands in LOS?

 cal - Displays a calendar


 date - print or set the system date and time
 bc - An arbitrary precision calculator language
 echo - Display a line of text.
 printf - Format and print data
 passwd - update user's authentication tokens
 who - Show who is logged on
 w - Show who is logged on and what they are doing
 uname - Print system information
 expr - Evaluate expressions
 test - Check file types and compare values
 seq - Print a sequence of numbers
 factor - Factor numbers
 rev - reverse lines of a file or files

Text Editors: vi and gedit


Vi
One of the first things to know about vi is that it typically functions in three
different modes:
1. Command mode
2. Insert mode
3. Last line mode

 When you first start editing a file with the vi editor you will be in vi command mode.
In this mode you can issue many vi commands, including commands like insert,
append, and delete, and other search and navigation commands that let you move
around your file.
 In command mode you cant insert text immediately. You first need to issue an insert,
append, or open command to insert text.

 INSERT MODE

3
Once you issue a vi insert, append, or open command, you will be in vi insert mode.
If
You’re working with a modern vi or vim implementation, your vi editor is typically
configured to show the current mode of operation, so when you go into insert mode,
you will see a text string like this on the last line of your vi editor window:
-- INSERT --
At this point you can (a) type text into your file and (b) use the arrow keys to
navigate
around your file just as you would do with any other text editor.
 LAST LINE MODE
The last vi mode is known as vi last line mode. You can only get to last line mode
from
command mode, and you get into last line mode by pressing the colon key, like this:
:
After pressing this key, you will see a colon character appear at the beginning of the
last line of your vi editor window, and your cursor will be moved to that position.
This indicates that vi is ready for you to type in a “last line command”.
You can do simple things from this command mode like quitting your vi session, like
this:
:q
or this:

:q!
or this:
:wq
From last line more you can also perform some amazing vi that tells vi to show lines
numbers in your current editor window:
:set shownumber

NAVIGATION THROUGH vi

1. Line navigation
2. Screen navigation
3. Word navigation
4. Special navigation
5. Paragraph navigation
6. Search navigation
7. Code navigation
8. Navigation from command line

1. Vim Line Navigation


Following are the four navigation that can be done line by line.
 k – navigate upwards

4
 j – navigate downwards
 l – navigate right side
 h – navigate left side

By using the repeat factor in VIM we can do this operation for N times. For example,
when
you want to
go down by 10 lines, then type “10j”.

Within a line if you want to navigate to different position, you have 4 other options.
 0 – go to the starting of the current line.
 ^ – go to the first non blank character of the line.
 $ – go to the end of the current line.
 g_ – go to the last non blank character of the line.
2. Vim Screen Navigation
Following are the three navigation which can be done in relation to text shown in the
screen.
 H – Go to the first line of current screen.
 M – Go to the middle line of current screen.
 L – Go to the last line of current screen.
 ctrl+f – Jump forward one full screen.
 ctrl+b – Jump backwards one full screen
 ctrl+d – Jump forward (down) a half screen
 ctrl+u – Jump back (up) one half screen
3. Vim Special Navigation
You may want to do some special navigation inside a file, which are:
 N% – Go to the Nth percentage line of the file.
 NG – Go to the Nth line of the file.
 G – Go to the end of the file.
 `” – Go to the position where you were in NORMAL MODE while last closing the
 file.
 `^ – Go to the position where you were in INSERT MODE while last closing the
 file.
 g – Go to the beginning of the file.
4. Vim Word Navigation
You may want to do several navigation in relation to the words, such as:
 e – go to the end of the current word.
 E – go to the end of the current WORD.
 b – go to the previous (before) word.
 B – go to the previous (before) WORD.
 w – go to the next word.
 W – go to the next WORD.

WORD – WORD consists of a sequence of non-blank characters, separated with


white

5
space.
word – word consists of a sequence of letters, digits and underscores.
Example to show the difference between WORD and word
 192.168.1.1 – single WORD
 192.168.1.1 – seven words.
5. Vim Paragraph Navigation
 { – Go to the beginning of the current paragraph. By pressing { again and again
 move to the previous paragraph beginnings.
 } – Go to the end of the current paragraph. By pressing } again and again
move to
 the next paragraph end, and again.
6. Vim Search Navigation
 /i – Search for a pattern which will you take you to the next occurrence of it.
 ?i – Search for a pattern which will you take you to the previous occurrence
of it.
 * – Go to the next occurrence of the current word under the cursor.
 # – Go to the previous occurrence of the current word under the cursor.
7. Vim Code Navigation
 % – Go to the matching braces, or parenthesis inside code.
8. Vim Navigation from Command Line
Vim +N filename: Go to the Nth line of the file after opening it.
vim +10 /etc/passwd

Vim +/pattern filename: Go to the particular pattern’s line inside the file, first
occurrence
from first. In the following example, it will open the README file and jump to the
first
occurrence of the word “install”.
vim +/install README

Vim +?patten filename: Go to the particular pattern’s line inside the file, first
occurrence
from last. In the following example, it will open the README file and jump to the last
occurrence of the word “bug”.
vim +?bug README
Gedit

File System
In computing, a file system (or filesystem) is used to control how data is stored and
retrieved. Taking its name from the way paper-based information systems are named, each
group of data is called a "file". The structure and logic rules used to manage the groups of
information and their names is called a "file system"

6
File system Architecture

1. / – Root
 Every single file and directory starts from the root directory.
 Only root user has write privilege under this directory.
 Please note that /root is root user’s home directory, which is not same as /.

2. /bin – User Binaries


 Contains binary executables.
 Common linux commands you need to use in single-user modes are located under this directory.
 Commands used by all the users of the system are located here.
 For example: ps, ls, ping, grep, cp.

3. /sbin – System Binaries


 Just like /bin, /sbin also contains binary executables.
 But, the linux commands located under this directory are used typically by system aministrator, for system
maintenance purpose.
 For example: iptables, reboot, fdisk, ifconfig, swapon

7
4. /etc – Configuration Files
 Contains configuration files required by all programs.
 This also contains startup and shutdown shell scripts used to start/stop individual programs.
 For example: /etc/resolv.conf, /etc/logrotate.conf

5. /dev – Device Files


 Contains device files.
 These include terminal devices, usb, or any device attached to the system.
 For example: /dev/tty1, /dev/usbmon0

6. /proc – Process Information


 Contains information about system process.
 This is a pseudo filesystem contains information about running process. For example: /proc/{pid} directory
contains information about the process with that particular pid.
 This is a virtual filesystem with text information about system resources. For example: /proc/uptime

7. /var – Variable Files


 var stands for variable files.
 Content of the files that are expected to grow can be found under this directory.
 This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print
queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);

8. /tmp – Temporary Files


 Directory that contains temporary files created by system and users.
 Files under this directory are deleted when system is rebooted.

9. /usr – User Programs


 Contains binaries, libraries, documentation, and source-code for second level programs.
 /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under
/usr/bin. For example: at, awk, cc, less, scp
 /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look
under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
 /usr/lib contains libraries for /usr/bin and /usr/sbin
 /usr/local contains users programs that you install from source. For example, when you install apache from
source, it goes under /usr/local/apache2

10. /home – Home Directories


 Home directories for all users to store their personal files.
 For example: /home/john, /home/nikita

11. /boot – Boot Loader Files


 Contains boot loader related files.
 Kernel initrd, vmlinux, grub files are located under /boot
 For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic

12. /lib – System Libraries


 Contains library files that supports the binaries located under /bin and /sbin
 Library filenames are either ld* or lib*.so.*
 For example: ld-2.11.1.so, libncurses.so.5.7

8
File Types

- Ordinary or Regular File


d Directory
c Character special file
b Block special file
l Symbolic link
p Named pipe
s Socket

Ordinary or Regular Files


A large majority of the files found on UNIX and Linux systems are ordinary files. Ordinary
files contain ASCII (human-readable) text, executable program binaries, program data, and
more.
Directories
A directory is a binary file used to track and locate other files and directories. The binary
format is used so that directories containing large numbers of filenames can be search
quickly.
Device (Special) Files
Device or special files are used for device I/O on UNIX and Linux systems. They appear in a
file system just like an ordinary file or a directory.
Linux systems there are two flavors of special files for each device, character special files
and block special files. Linux systems only provide one special file for each device.
When a character special file is used for device I/O, data is transferred one character at a
time. This type of access is called raw device access.
When a block special file is used for device I/O, data is transferred in large fixed-size blocks.
This type of access is called block device access.
Links
A link is a tool used for having multiple filenames that reference a single file on a physical
disk. They appear in a file system just like an ordinary file or a directory.
Like special files, links also come in two different flavors. There are hard links and symbolic
links.
Hard links do not actually link to the original file. Instead they maintain their own copy of
the original file's attributes (i.e. location on disk, file access permissions, etc.). If the original
file is deleted, its data can still be accessed using the hard link.

9
On the other hand, symbolic links contain a pointer, or pathname, to the original file. If the
original file is deleted, its data can no longer be accessed using the symbolic link, and the
link is then considered to be a stale link.
Named Pipes

Named pipes are tools that allow two or more system processes to communicate
with each other using a file that acts as a pipe between them. This type of
communication is known as interprocess communication, or IPC for short.

Sockets

Sockets are also tools used for interprocess communication. The difference between sockets
and pipes is that sockets will facilitate communication between processes running on
different systems, or over the network.
With so many different types of files, it's often wise to identify a file's type before
performing any operation with it. The ls -l command and the file command are useful for
determining file types.
Consider the long listing of the livefirelabs1 file:

-rw-rw-r-- 1 student1 student1 0 Jun 27 18:55 livefirelabs1

The first character of the first field indicates the file type. In this example, the first character
is a - (hyphen) indicating that livefirelabs1 is an ordinary or regular file.

Consider the long listing of the live1 file:


lrwxrwxrwx 1 student1 student1 13 Jun 27 17:57 live1 -> livefirelabs1

The first character of the first field is the letter l indicating live1 is a symbolic link.
File Attributes

Type:
Whether ordinary, directory, device, etc.

Permissions:
Determines who can read, write or execute a file.

Links:
Number of hard links to the file. A number of files in the file system can actully reference
the same file on the drive.

Owner:
A file is owned by a user, by default its creator. The owner can change many file attributes
and set the permissions.

Group Owner:
The group which owns the file. The owner by default belongs to this group.

10
File Size:
Number of bytes of data contained.

File Time Stamps:


Date and time of last modification
Date and time of last access

File Naming Conventions

 A Linux file name may have any characters or letters.


 Maximum length for file name is 256 characters.
 File name can use space, underscore, minus, period and comma.
 File name cannot use question marks, asterisks and slashes.as they are reserved for
shell functions
 File extension is not compulsory. We can create files with file extension or without
file extension.A file extention is created with a dot.
 To create a hidden file, start its name with dot.
 If file name has spaces, it need to be quoted before we can access it on command
prompt. On desktop we can use it without quotes.
 All file names are case sensitive. So filename vivek.txt Vivek.txt VIVEK.txt all are
three different file names

Shell As Interpreter

It is a command language interpreter that executes commands read from the standard input
device such as keyboard or from a file. The shell gets started when you log in or open a
console (terminal). The shell is not part of system kernel, but uses the system kernel to
execute programs, create files etc.

[In computing, a shell is a user interface for access to an operating system's services.]

Types of Shell
B shell - /bin/sh – This is the default Unix shell for many Unix operating systems .
Bourne shell was written by S. R. Bourne and its more emphasis is to use it as a scripting
language rather than an interactive shell .
C-shell /bin/csh was designed to provide the interactive features lacking in b shell such as
job control and aliasing .
K shell /bin/ksh – was created by David Korn and has features of both B shell and C shell
along with some additional features . It also includes the ability for developers to create new
shell commands as the need arises.
Bash – the Bourne again shell was developed by GNU project .It is based on B shell language
and has features of C and K shells.
tcsh is the default shell of FreeBSD and its descendants. Essentially it is C shell with
programmable command line completion, command-line editing, and a few other features.
Zsh is a shell designed for interactive use and it has many of the useful features of bash, ksh,
and tcsh along with many new features.

11
To find your current shell type following command
$ echo $SHELL

Command line, Command Syntax


A command line, or terminal, is a text based interface to the system. You are able to enter
commands by typing them on the keyboard and feedback will be given to you similarly as
text.

Line 1 presents us with a prompt ( user@bash ). After that we entered a command ( ls ).


Typically a command is always the first thing you type. After that we have what are referred
to as command line arguments ( -l /home/ryan ). Important to note, these are separated by
spaces (there must be a space between the command and the first command line argument
also). The first command line argument ( -l ) is also referred to as an option. Options are
typically used to modify the behaviour of the command. Options are usually listed before
other arguments and typically start with a dash ( - ).

Lines 2 - 5 are output from running the command. Most commands produce output and it
will be listed straight under the issuing of the command. Other commands just perform their
task and don't display any information unless there was an error.
Line 6 presents us with a prompt again. After the command has run and the terminal is
ready for you to enter another command the prompt will be displayed. If no prompt is
displayed then the command may still be running (you will learn later how to deal with this).
Another Example-
user@Linux-003 ~ $
For this particular case following code means:
Somebody with user name "user" has logged in to the machine with host name "Linux-003".
"~" - represent the home folder of the user, conventionally it would be /home/user/, where
"user" is the user name can be anything like /home/johnsmith.
"$" - is just a sign of the shell prompt, means that shell is ready to accept commands, you
can understand it as a separator after which, you can interact with a shell. Can also be "#"
which shows that root is the user who's session is going on.

12
Running Commands and getting Help
Basic Commands
1. ls

The ls command - the list command - functions in the Linux terminal to show all of the major
directories filed under a given file system. For example, the command:

ls /applications
...will show the user all of the folders stored in the overall applications folder.
The ls command is used for viewing files, folders and directories.

2. cd

The cd command - change directory - will allow the user to change between file directories. As the
name command name suggest, you would use the cd command to circulate between two different
directories. For example, if you wanted to change from the home directory to the Arora directory,
you would input the following command:

cd/arora/applications
As you might have noted, the path name listed lists in reverse order.
Logically cd/arora/applications reads change to the arora directory which is stored in the
applications directory. All Linux commands follow a logical path.

3. mv

The mv command - move - allows a user to move a file to another folder or directory. Just like
dragging a file located on a PC desktop to a folder stored within the "Documents" folder, the mv
command functions in the same manner. An example of the mv command is:
mv/arora/applications/majorapps /arora/applications/minorapps
The first part of the command mv/arora/applications/majorapps lists the application to be moved. In
this case, arora. The second part of the command /arora/applications/minorapps lists where arora
will be moved to - from majorapps to minorapps.

4. man

The man command - the manual command - is used to show the manual of the inputted command.
Just like a film on the nature of film, the man command is the meta command of the Linux CLI.
Inputting the man command will show you all information about the command you are using. An
example:

man cd

The inputting command will show the manual or all relevant information for the change directory
command.

5. mkdir

13
The mkdir - make directory - command allows the user to make a new directory. Just like making a
new directory within a PC or Mac desktop environment, the mkdir command makes new directories
in a Linux environment. An example of the mkdir command

mkdir testdirectory

The example command made the directory "testdirectory".

6. rmdir

The rmdir - remove directory - command allows the user to remove an existing command using the
Linux CLI. An example of the rmdir command:

rmdir testdirectory

7. touch

The touch command - a.k.a. the make file command - allows users to make files using the Linux CLI.
Just as the mkdir command makes directories, the touch command makes files. Just as you would
make a .doc or a .txt using a PC desktop, the touch command makes empty files. An example of the
touch command:

touch testfile.txt

The example touch command effectively created the file testfile.txt

8. rm

The rm command - remove - like the rmdir command is meant to remove files from your Linux OS.
Whereas the rmdir command will remove directories and files held within, the rm command will
delete created files. An example of the rm command:

rm testfile.txt

The aforementioned command removed testfile.txt. Interestingly, whereas the rmdir command will
only delete an empty directory, the rm command will remove both files and directories with files in
it. This said, the rm command carries more weight than the rmdir command and should be used with
more specificity.

9. locate

The locate - a.k.a. find - command is meant to find a file within the Linux OS. If you don't know the
name of a certain file or you aren't sure where the file is saved and stored, the locate command
comes in handy. A locate command example:

locate -i *red*house**city*

14
The stated command will locate an file with the a file name containing "Red", "House" and "City". A
note on the input: the use of "-i" tells the system to search for a file unspecific of capitalization
(Linux functions in lower case). The use of the asterik "*" signifies searching for a wildcard. A
wildcard tells the system to pull any and all files containing the search criteria.

By specifying -i with wildcards, the locate CLI command will pull back all files containing your search
criteria effectivley casting the widest search net the system will allow.

10. clear

The clear command does exactly what it says. When your Linux CLI gets all mucked up with various
eadouts and information, the clear command clears the screen and wipes the board clean. Using the
clear command will take the user back to the start prompt of whatever directory you are currently
operating in. To use the clear command simply type clear.

File Directory Handling Commands

 Cd
 rm
 find
 pwd
 mkdir
 rmdir
 cp
 man
 cat

Locating Files

The command used to search for files is called find.

Here is the basic syntax of the Find command.

find

The starting point is the folder where you want to start searching from. To start searching the whole
drive you would type the following:

find /

If however, you want to start searching for the folder you are currently in then you can use the
following syntax:

find .

Generally, when searching you will want to search by name, therefore, to search for a file
called myresume.odt across the whole drive you would use the following syntax:

15
find / -name myresume.odt

The first part of the find command is obviously the word find.

The second part is where to start searching from

The next part is an expression which determines what to find.

Finally the last part is the name of the thing to find.

Where To Start Searching From

 If you want to search for the current file system you can use a full stop as follows:

find . -name game

The above command will look for a file or folder called the game in all folders under the current folder.
You can find the name of the current folder using the pwd command.

 If you want to search the entire file system then you need to start at the root folder as follows:

find / -name game

 The starting position can be literally anywhere on your file system. For example to search for
the home folder type the following:

find ~ -name game

The tilde is a metacharacter commonly used for denoting the home folder of the current user.

Expressions

The most common expression you will use is -name.

The -name expression lets you search for the name of a file or folder.

There are however other expressions you can use as follows:

 -amin n - The file was last accessed n minutes ago


 -anewer - The file was last accessed more recently than it was modified
 -atime n - The file was last accessed more n days ago
 -cmin n - The file was last changed n minutes ago
 -cnewer - The file was last changed more recently than the file was modified
 -ctime n - The file was last changed more than n days ago
 -empty - The file is empty
 -executable - The file is executable

 -false - Always false


 -fstype type - The file is on the specified file system
 -gid n - The file belongs to group with the ID n
 -group groupname - The file belongs to the named group
 -ilname pattern - Search for a symbolic line but ignore case
 -iname pattern - Search for a file but ignore case
 -inum n - search for a file with the specified node
 -ipath path - search for a path but ignore case
 -iregex expression - search for a expression but ignore case
 -links n - search for a file with the specified number of links
 -lname name - search for a symbolic link
 -mmin n - file's data was last modified n minutes ago

16
 -mtime n - file's data was last modified n days ago
 -name name - search for a file with the specified name
 -newer name - search for a file edited more recently than the file given
 -nogroup - search for a file with no group id
 -nouser - search for a file with no user attached to it
 -path path - search for a path
 -readable - find files which are readable
 -regex pattern - search for files matching a regular expression
 -type type - search for a particular type
 -uid uid - files numeric user id is the same as uid
 -user name - file is owned by user specified
 -writable - search for files that can be written to

How To Find Empty Files And Folders

If you want to find all the empty files and folders in your system use the following command:

find / -empty

How To Find All Of The Executable Files

If you want to find all of the executable files on your computer use the following command:

find / -exec

How To Find All Of The Readable Files

To find all of the files that are readable use the following command:

find / -read

Patterns

When you search for a file you can use a pattern. For example, maybe you are searching for all files
with the extension mp3.

You can use the following pattern:

find / -name *.mp3

Time
Linux stores time data about access times, modification times, and change times.
 Access Time: Last time a file was read or written to.
 Modification Time: Last time the contents of the file were modified.
 Change Time: Last time the file's inode meta-data was changed.
We can use these with the "-atime", "-mtime", and "-ctime" parameters. These can use the
plus and minus symbols to specify greater than or less than, like we did with size.
The value of this parameter specifies how many days ago you'd like to search.
To find files that have a modification time of a day ago, type:
find / -mtime 1
If we want files that were accessed in less than a day ago, we can type:
find / -atime -1
To get files that last had their meta information changed more than 3 days ago, type:
find / -ctime +3
There are also some companion parameters we can use to specify minutes instead of days:
find / -mmin -1

17
This will give the files that have been modified type the system in the last minute.
Find can also do comparisons against a reference file and return those that are newer:
find / -newer myfile
Finding by Owner and Permissions
You can also search for files by the file owner or group owner.
You do this by using the "-user" and "-group" parameters respectively. Find a file that is
owned by the "syslog" user by entering:
find / -user syslog
Similarly, we can specify files owned by the "shadow" group by typing:
find / -group shadow
We can also search for files with specific permissions.
If we want to match an exact set of permissions, we use this form:
find / -perm 644
This will match files with exactly the permissions specified

LOCATE
To find files with locate, simply use this syntax:
locate query
You can filter the output in some ways.
For instance, to only return files containing the query itself, instead of returning every file
that has the query in the directories leading to it, you can use the "-b" for only searching the
"basename":
locate -b query

File Access Permission

Permission Groups
Each file and directory has three user based permission groups:

 owner - The Owner permissions apply only the owner of the file or
directory, they will not impact the actions of other users.
 group - The Group permissions apply only to the group that has been
assigned to the file or directory, they will not effect the actions of other
users.
 all users - The All Users permissions apply to all other users on the system,
this is the permission group that you want to watch the most.

Permission Types
Each file or directory has three basic permission types:

 read - The Read permission refers to a user's capability to read the


contents of the file.
 write - The Write permissions refer to a user's capability to write or modify
a file or directory.
 execute - The Execute permission affects a user's capability to execute a
file or view the contents of a directory.

Viewing the Permissions


18
You can view the permissions by checking the file or directory permissions in your
favorite GUI File Manager by reviewing the output of the \"ls -l\" command while
in the terminal and while working in the directory which contains the file or folder.
The permission in the command line is displayed as: _rwxrwxrwx 1 owner:group
1. User rights/Permissions
1. The first character that is marked with an underscore is the special
permission flag that can vary.
2. The following set of three characters (rwx) is for the owner
permissions.
3. The second set of three characters (rwx) is for the Group permissions.
4. The third set of three characters (rwx) is for the All Users
permissions.
2. Following that grouping since the integer/number displays the number of
hardlinks to the file.
3. The last piece is the Owner and Group assignment formatted as
Owner:Group.
4. Modifying the Permissions
5. When in the command line, the permissions are edited by using the
command chmod. You can assign the permissions explicitly or by using a
binary reference as described below.
6. So for an example, lets say I have a file named file1 that currently has the
permissions set to _rw_rw_rw, which means that the owner, group and all
users have read and write permission. Now we want to remove the read and
write permissions from the all users group.
7. To make this modification you would invoke the command: chmod a-rw
file1
To add the permissions above you would invoke the command: chmod a+rw
file1
Using Binary References to Set permissions
A sample permission string would be chmod 640 file1, which means that the
owner has read and write permissions, the group has read permissions, and all
other user have no rights to the file.
The first number represents the Owner permission; the second represents the
Group permissions; and the last number represents the permissions for all other
users. The numbers are a binary representation of the rwx string.

 r=4
 w=2
 x=1

19
You add the numbers to get the integer/number representing the permissions you
wish to set. You will need to include the binary permissions for each of the three
permission groups.
So to set a file to permissions on file1 to read _rwxr_____, you would enter chmod
740 file1.
Owners and groups
You use the chown command to change owner and group assignments, the syntax is
simplechown owner:group filename, so to change the owner of file1 to user1 and the group
to family you would enter chown user1:family file1.

20

You might also like