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

Lab 2 Commands

This document provides information on Linux commands and file permissions. It describes commands for changing directories (cd), listing directory contents (ls), creating/viewing files (cat), copying/moving files (cp, mv), deleting files/directories (rm, rmdir), comparing/converting files (cmp, diff), and compressing files (gzip, zip). It also explains the components of file permissions displayed using ls -l, including owner, group, permissions for user/group/other, and special file types.

Uploaded by

YASH KAMRA
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lab 2 Commands

This document provides information on Linux commands and file permissions. It describes commands for changing directories (cd), listing directory contents (ls), creating/viewing files (cat), copying/moving files (cp, mv), deleting files/directories (rm, rmdir), comparing/converting files (cmp, diff), and compressing files (gzip, zip). It also explains the components of file permissions displayed using ls -l, including owner, group, permissions for user/group/other, and special file types.

Uploaded by

YASH KAMRA
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

• passwd : change password

• pwd :displays present working directory


• cd : change directory
• mkdir: making directories
• rmdir : remove directories (removes empty directories only)
• Use rm –r for deleting non empty directories.
• ls : list the directory contents
• ls -l (additional information)
• cat : display and create files
• cat filename : displays contents of file
• cat > filename : creates the file and asks for writing contents to file
• cp : copying a single or group of files
• cp - i: for interactive copying
• cp –R is used for copying directories (cp –R d1 d2)
• rm: deletes files
• rm - i: for interactive deletion
• mv : for moving files/directories to other directories OR for renaming files/dir
• mv f1 f2 (renames f1 as f2)
• mv f1 d1 (moves f1 in d1)
• mv f1 ../ (moves f1 to parent directory)
• wc: counts lines words and characters in a file.
• wc file_name
• wc -l file_name: for line count
• wc –w file_name: for word count
• wc –c file_name: for number of characters
• cmp: compare two files
• cmp file1 file2
• comm: to find what is common in two files
• comm file1 file2 OR comm file[12]
• diff: convert one file to other
• diff file1 file2
• gzip: compression (with .gz extension)
• gzip filename(with extension)
• gzip –l compressed filename: gives compression ratio
• gunzip: decompression
• zip and unzip: for compression and archiving together
File Permissions

When we type:
ls -l File1
We'll see:
-rwxr-xr-x 1 owner groupowner 68524 2011-12-19 07:18 File1

What does all this mean?


-r-xr-xr-x 1 owner groupowner 68524 2011-12-19 07:18 File1

---------- --- ------- ------- -------- ------------ -------------


| | | | | | |
| | | | | | File Name
| | | | | |
| | | | | +--- Modification Time/Date
| | | | |
| | | | +------------- Size (in bytes
| | | |
| | | +----------------------- Group
| | |
| | +-------------------------------- Owner
| |
| +-------------------------------------- “link count”
|
+---------------------------------------------- File Permissions
Group
The name of the group that has permissions in addition to the file's owner.
Owner
The name of the user who owns the file.
File Permissions
The first character is the type of file. A "-" indicates a regular (ordinary) file. A
"d” indicate a directory. Second set of 3 characters represent the read, write, and
execution rights of the file's owner. Next 3 represent the rights of the file's group, and
the final 3 represent the rights granted to everybody else.
Access rights

Files are owned by a user and a group


(ownership)
Files have permissions for the user, the group,
and other
“other” permission is often referred to as “world”
The permissions are Read, Write and Execute
(R, W, X)
The user who owns a file is always allowed to
change its permissions
Some special cases

When looking at the output from “ls -l” in the


first column you might see:
d = directory
- = regular file
l = symbolic link
s = Unix domain socket
p = named pipe
c = character device file
b = block device file

You might also like