Learning

Linux for Starters: Your Guide to Linux – Files and Permissions – Part 10

Last Updated on May 22, 2022

What does the long listing of files mean?

Let’s breakdown the ls output.

Linux for Starters - breakdown of ls output

  • The first column gives the type of the file (e.g. directory or ordinary file) and the file permissions. We’ll cover file permissions in the section below.
  • The second column is the number of links to the file.
  • The third column shows the owner of the file. In our example, all the files are owned by the user sde.
  • The fourth column shows the group of users to which the file belongs.
  • The fifth column is the size of the file (in our example it’s shown in human readable format).
  • The next three columns show the time when the file was last changed (for a directory, this is the time when a file in that directory was last created or deleted).
  • The final column is the name of the file.

File Permissions

File permissions provide a way of controlling who can read and modify files.

Let’s look at the file permission for the file Licence.txt.

-rw-rw-r--    1    sde   sde 1.1K    Jun 21 14:24 Licence.txt

As we explained in the first section the first character indicates the file type. Here it’s a – because License.txt is an ordinary file.

The next nine characters fall into three sets of three characters, indicating permissions for owner, group, and other.

  • r = readable
  • w = writeable
  • x = executable (for files) or accessible (for directories)

For the Licence.txt file, sde (the user who owns the file) has the access rights rw- means that he can read and write the file but not execute it (as it’s a plain text file). Any user in the group sde has the same permissions. Everyone else has the access rights of r--, meaning they can read the file but not write or execute it.


chmod (change mode) utility

The chmod (change mode) utility allows us to add or remove permissions. There are two types of syntax, the simpler “character” syntax and the numeric “octal” syntax. We’ll describe the simpler “character” syntax.

Here’s some examples of modifying permissions for the file email.cpp

-rwxrwxr-x    1    sde   sde 4.4K    Jun 21 14:27 email.cpp

chmod g-w email.cpp – this command removes write permission for group.

chmod go-rwx email.cpp – this command removes read, write, and execute permission for group and others.

chmod o+w email.cpp – this command adds write permission for others.

Page 3 – Installing Hyper

Pages in this article:
Page 1 – ls – list the contents of a directory
Page 2 – What does the long listing mean?
Page 3 – Appendix: Installing Hyper


All articles in this series:

Linux For Starters: Your Guide to Linux
1What is Linux? Why use Linux? What do I need?
2Choose a Linux distribution meeting your specific needs and requirements.
3Make a bootable Ubuntu USB stick in Windows.
4We show you how to install Ubuntu 21.04 on your hard disk.
5Things to do after installing Ubuntu.
6Navigating your way around the Desktop.
7Updating the system, install new software.
8Open source replacements for proprietary Windows desktop software.
9Get started with the power and flexibility of the terminal.
10We cover the basics of files and permissions.
11Getting help from your system.
12Learn all about the file system.
13Manipulating files from the shell.
14Maintain your system with these simple tips.
15Managing users on your system.
16Explore different desktops to GNOME 3.
17Gaming on Linux.
18Protect your privacy with this guide.
19Access the Windows desktop from Linux using a remote desktop client.
20Set up a virtual machine running Ubuntu as the host and openSUSE as the guest.
21Wine lets you run Windows programs on Linux without emulation.
22Extend your GNOME desktop with extensions and themes.
XUseful Linux commands.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Please read our Comment FAQ before posting a comment.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments