0% found this document useful (0 votes)
10 views4 pages

Lab - OS 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Lab - OS 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Basic Unix commands: who, 1s, ln, cp, rm, mv,


chmod, chown, mkdir, rmdir, pwd,cd and so on.

1. who
● Usage: Displays information about users currently logged
into the system.
who

2. ls
● Usage: Lists files and directories in the current directory.
ls

3. ln
● Usage: Creates links between files. Can be used to create
hard or soft (symbolic) links.
ln file1 link1 # Hard link
ln -s file1 link1 # Symbolic (soft) link

4. cp
● Usage: Copies files or directories.
cp file1 file2 # Copy file1 to file2
cp -r dir1 dir2 # Copy directory dir1 to dir2

5. rm
● Usage: Removes files or directories.
rm file1 # Remove file1
rm -r dir1 # Remove directory dir1 and its contents

6. mv
● Usage: Moves or renames files or directories.
mv file1 newname # Rename file1 to newname
mv file1 /newdir/ # Move file to directory /newdir/

7. chmod
● Usage: Changes the file permissions.
chmod 755 file1
# Give owner read, write, and execute; others read and execute

chmod +x script.sh # Make script executable

8. chown
● Usage: Changes the ownership of files or directories.

chown user:group file1 # Change owner of file1 to user


and group to group

9. mkdir
● Usage: Creates a new directory.

mkdir newdir # Create a directory named newdir

10. rmdir
● Usage: Removes empty directories.

rmdir newdir # Remove empty directory newdir

11. pwd
● Usage: Prints the working directory (the directory you are
currently in).
pwd

12. cd
● Usage: Changes the current directory.

cd /path/to/directory # Change to the specified directory


cd .. # Move up one directory

13. touch
● Usage: Creates a new empty file or updates the timestamp
of an existing file.
touch newfile # Create a new file named newfile

14. cat
● Usage: Displays the contents of a file.

cat file1 # Show the contents of file1

15. echo
● Usage: Displays a line of text or the value of a variable.

echo "Hello, World!"

16. man
● Usage: Displays the manual or help page for a specific
command.

man ls # Show the manual for the 'ls' command

17. grep
● Usage: Searches for patterns in files.

grep 'pattern' file1 # Search for 'pattern' in file1

You might also like