Linux Files - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Linux Files

Description:

... a database, a shell script, or any other collection of bytes that has meaning. ... For example, ug x would add execute privileges for the user and members of the ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 17
Provided by: Harr228
Category:

less

Transcript and Presenter's Notes

Title: Linux Files


1
Linux Files
2
File Characteristics
  • To the average user, a file is a sequence of
    information bytes, stored together and named as a
    collective entity. A file can be an executable
    program, a document, a database, a shell script,
    or any other collection of bytes that has
    meaning. In fact, virtually everything in Linux
    is seen by the system as a file, including the
    directories and devices.

3
File Characteristics
  • Filenames in Linux can range up to 255 characters
    and may or may not be terminated with an
    extension. Filenames are case sensitive, like
    nearly everything else in Linux. This means that
    the names File.txt, FILE.txt, file.txt, and
    FiLe.txt would all refer to different files.

4
Determining a Linux Files Type
  • You can use commands like ls and file to
    determine the type.
  • The file command was created to allow a user to
    determine a files type and is the best tool for
    this purpose. The format for the file command is
  • file options -f namefile -m magicfiles
    file
  • The ls command is one of the most often used
    Linux commands . ls provides information about a
    file, including its type. The name ls means
    listing because the commands lists all of the
    files in a directory. The syntax for ls is
    simple
  • ls options file or directory name

5
The file command
  • The ls command doesnt differentiate between the
    various normal file types, the file command
    does. The file command is supported by a file
    named magic (/usr/share/magic by default on a Red
    Hat system) which contains information on all the
    file types that the file command knows about. The
    f option reads in a file which contains names of
    files whose type is to be determined. You can
    specify a different magic file with the m option
    on the command line. The file command will use
    this magic file to determine, to the best of its
    knowledge, what type of file youve specified.
    The file commands output will usually include
    one of the following key words text, executable,
    or data.

6
File Types Defined
File Types Recognized by ls
7
File-Handling Commands
8
chmod
  • SYNTAX
  • chmod options mode(s) filename(s)
  • chmod options octal_mode(s) filename(s)
  • The chmod command is used to change the access
    mode of files. Only the owner of the file or the
    superuser may alter its access. There are two
    methods for the expressing the mode you wish to
    assign. The first is the symbolic method, wherein
    you specify letters representing the mode. This
    requires that you specify the following
    information.

9
chmod
  • Who is affected
  • u User who owns the file
  • g Group (only users in files group)
  • o Other users
  • a All (default)
  • What operation
  • Add permission
  • - Remove permission
  • Set permission, overwriting old
    permissions

10
chmod
  • What kind of permission
  • r Read
  • w Write
  • x Execute
  • s User or group ID is temporarily replaced
    with that of the file
  • t Set sticky bit keep executable in memory
    after exit

11
chmod
  • For example, ugx would add execute privileges
    for the user and members of the group, and orw
    would allow other users not in the specified
    group to read and write the file.

12
chmod (octal mode)
  • Some administrators prefer the octal method,
    which uses a sequence of three numbers to
    represent the permissions for the user, group,
    and others. The new permissions completely
    override the previous assignment. Three digits
    are computed, representing the user, group, and
    others, respectively.

13
chmod (octal mode)
  • To compute them, you add up the integers
    corresponding to the permissions you wish to
    grant each level. The result is a three-digit
    number in which the first number represents the
    User permissions, the second the Group
    permissions, and the third the Other permissions.
    The values assigned to each permission are as
    follows
  • Execute
  • Write
  • 4 Read

14
chmod (octal mode)
  • Thus, read and write permissions would assign a 6
    (24). Read, write, and execute would assign a 7
    (124). Using this method, 755 would grant the
    user read, write, and execute privileges, and
    both group members and all others would have read
    and execute.

15
chown
  • SYNTAX
  • chown options newowner filename(s)
  • chown options newowner.newgroup filename(s)
  • The chown command changes the owner of the
    specified file or files to the owner listed as an
    argument. This command can also be used to change
    both the owner and the group settings on the
    specified file. To do this, append a period
    followed by the new group to the owner name.

16
chgrp
  • SYNTAX
  • chgrp options newgroup filename
  • The chgrp command is used to change only the
    group setting for the file. You must own the file
    or be the superuser to use this command. The new
    group may be specified by the group name or ID.
Write a Comment
User Comments (0)
About PowerShow.com