Monday, May 8, 2023
HomeNetworking4 methods to view information and file permissions on Linux

4 methods to view information and file permissions on Linux


There are a selection of the way to view information on Linux, as a result of, in any case, information on Linux are multifaceted. They’ve names, they’ve content material, they’ve entry permissions, and so they have dates and occasions related to their “start” (after they had been initially added to the file system) in addition to after they had been final modified and final accessed. This put up covers the instructions that will let you view all these particulars.

Itemizing information

The simplest and most evident option to checklist information is with the ls command. By default, ls will checklist information within the present listing in title order, however you’ll be able to reverse that by including the -r choice.

$ ls | head -3
4letters
4_vowel_words
4Vwords
$ ls -r | head -3
zoom-mtg
zodiac
zipfiles.bat

You’ll be able to checklist information in a tree-like vogue by utilizing the tree command. It can show the listing construction in a means that clearly signifies the listing ranges.

$ tree
.
│   ├── xtra
│   │   ├── date
│   │   ├── doit
│   │   ├── dt
│   │   ├── ex
│   │   ├── loop

Extra data on itemizing and viewing information can be found at these pages:

Viewing entry permissions

The ls command with the -l choice shows permissions within the “rwx” vogue. By including “a” to the choices, it is going to embrace information and directories that begin with a “,” (in any other case omitted).

$ ls -l | head -5
complete 120528
-rw-r-----.  1 shs  shs      66040 Jul  5  2022 4letters
-rw-r-----.  1 shs  shs        174 Jul  8  2022 4_vowel_words
-rw-r-----.  1 shs  shs        174 Jul  8  2022 4Vwords
-rw-r-----+  1 shs  shs     131310 Sep 19  2022 5letters
$ ls -al | head -5
complete 133480
drwxr-xr-x. 103 shs  shs      36864 Could  6 11:43 .
drwxr-xr-x.  25 root root      4096 Feb 17 11:36 ..
-rw-r-----.   1 shs  shs      66040 Jul  5  2022 4letters
-rw-r-----.   1 shs  shs        174 Jul  8  2022 4_vowel_words

You need to use the getfacl command to incorporate extra file entry permissions.

$ getfacl 5letters
# file: 5letters
# proprietor: shs
# group: shs
person::rw-
person:popeye:r--        <=====
group::r--
masks::r--
different::---

Discover that the command output above exhibits one person (popeye) who has learn entry to the file with out being a member of the related group or the file having entry permission for everybody.

Extra data on Linux permissions is offered at these pages:

Inspecting file content material

The cat, head and tail instructions will let you view file content material. Whereas cat will show the whole contents, you’ll be able to move the output to the extra command to view a screenful at a time. The head and tail instructions show strains on the high and backside of textual content information.

$ cat alert
REMINDER: This server will likely be shutting down @ 6PM tonight. Please end your
        work by 5:45 and log out.
$ cat 5letters | extra
aahed
aalii
aalst
aalto
aamsi
…

$ head -5 4letters
1080
tenth
AAAA
AAAL
AAAS

$ tail -5 4letters
zuza
ZWEI
zyga
zyme
Zysk

You need to use the grep command to select strains that include some content material that you’re on the lookout for and nothing else. The grep command beneath shows solely strains that start with a “z”.

$ grep ^z 4letters | tail -5
zulu
zuni
zuza
zyga
zyme

Extra protection on the head and tail instructions may be seen on this head and tail instructions video.

The od command will show file contents in a really totally different vogue. It shows the characters together with their octal values – helpful for troubleshooting.

$ od -bc alert
0000000 122 105 115 111 116 104 105 122 072 040 124 150 151 163 040 163
          R   E   M   I   N   D   E   R   :       T   h   i   s       s
0000020 145 162 166 145 162 040 167 151 154 154 040 142 145 040 163 150
          e   r   v   e   r       w   i   l   l       b   e       s   h
0000040 165 164 164 151 156 147 040 144 157 167 156 040 100 040 066 120
          u   t   t   i   n   g       d   o   w   n       @       6   P
0000060 115 040 164 157 156 151 147 150 164 056 040 120 154 145 141 163
          M       t   o   n   i   g   h   t   .       P   l   e   a   s
0000100 145 040 146 151 156 151 163 150 040 171 157 165 162 012 011 167
          e       f   i   n   i   s   h       y   o   u   r  n  t   w
0000120 157 162 153 040 142 171 040 065 072 064 065 040 141 156 144 040
          o   r   ok       b   y       5   :   4   5       a   n   d
0000140 154 157 147 040 157 146 146 056 012
          l   o   g       o   f   f   .  n
0000151

Extra particulars on the grep command can be found at The numerous faces of grep

Viewing file entry occasions

The stat command shows the date of a file’s “start” and when it was final modified and final accessed.

$ stat 4letters
  File: 4letters
  Dimension: 66040           Blocks: 136        IO Block: 4096   common file
Machine: 8,17    Inode: 3015994     Hyperlinks: 1
Entry: (0644/-rw-r--r--)  Uid: ( 1000/     shs)   Gid: ( 1000/     shs)
Context: unconfined_u:object_r:user_home_t:s0
Entry: 2023-05-06 12:14:49.279689941 -0400
Modify: 2022-07-05 10:06:54.798552673 -0400
Change: 2022-07-05 10:06:54.798552673 -0400
 Start: 2022-07-05 10:06:40.039362108 -0400

The date -r command will also be used to indicate a file’s final modification time, although it does so in a distinct format than the stat command.

$ date -r 4letters
Tue Jul  5 10:06:54 AM EDT 2022

Wrap-up

A useful number of Linux instructions may also help you see something about information that you just wish to see. Strive the instructions on this put up and it’s possible you’ll discover they they’re much more helpful than you anticipated.

Copyright © 2023 IDG Communications, Inc.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments