≡ Menu

ls command

Linux / UNIX – Display the permissions of a file

Q. How do I list or display the permission of a file using ssh? I don’t have GUI installed on a remote Linux computer.

A.You need to use ls command with -l option. File access permissions are displayed in the first column of the output, after the character for file type.

ls command List information about the FILEs. If no argument is given it will use the current directory by default.

Task: List a file's access permissions

Type ls -l command as follows to display permission for /etc/passwd file:
$ ls -l /etc/passwd

-rw-r--r-- 1 root root 2453 Jul 17 16:25 /etc/passwd

Understanding the file permission

File access permissions appear in the first column of the output i.e. -rw-r--r--

  • The first character - is nothing but the file type. means regular file and d means directory.
  • The next three characters (rw-) specify permissions for the user who owns the file
  • The next three (r--) specify permissions for all members of the group that owns the file.
  • Finally, the last three characters in the column (r--) specify permissions for all other users on the system.

Each character in permission has meaning as follows:

  • r : Read permission.
  • w : Write permission.
  • x : Execute permission.
  • - : No permission.

For example rw- permission means owner can read, write to a file but cannot execute the same.

Linux/UNIX: Argument list too long error for rm, cp, mv commands in a shell error

I'm a new Linux user. We have a backup server and most our developers sftp or ftp to upload files. I just need to backup of last four weeks. If I try to list or remove directories I get an error cannot remove directory. I'm getting "Argument list too long" message. How do I solve this problem when executing commands in the bash/ksh/csh/tcsh/zsh shell?
[click to continue…]

Bash Shell: Display All Hidden Dot Files In a Directory

How do I display only hidden (dot) files names under Linux / UNIX / Apple OS X / *BSD family operating systems?
[click to continue…]

HowTo: Linux / UNIX List Just Directories Or Directory Names

How do I list just directory names on a Linux and UNIX-like operating systems?
[click to continue…]

Bash Find All File Names With White Spaces

How do I find all files with one ore more blank space (while spaces) in their name under UNIX like operating systems?
[click to continue…]