100% found this document useful (1 vote)
28 views

Linux Assignment

Ls -l command is used to display the properties of all files and folders in current directory. Rm -fr run removes all the directories which ends with "run" in the present directory. Show the disk free space on one or more file systems df e. Show how much disk space a directory and all its files contain.

Uploaded by

12345678987t55
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
28 views

Linux Assignment

Ls -l command is used to display the properties of all files and folders in current directory. Rm -fr run removes all the directories which ends with "run" in the present directory. Show the disk free space on one or more file systems df e. Show how much disk space a directory and all its files contain.

Uploaded by

12345678987t55
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Linux Assignment

Date: 26-02-2011

Name: Arun kumar S D

Reg. No: 101006111

1. Write a small shell script that adds an extension “.new” to all the files in a directory?

 #! /bin/bash
For file in `ls`
do
mv $file $file.new
done

2. What is the difference between listing the content of directory play with ls –l and ls –L?

ls –l command is used to display the properties of all files and folders in current
directory. Properties may be file permissions, id, time, size ect.

ls –L command is used to display the information about the symbolic link references
for the files.

3. Write the command which is used to

a. Change the owner


chown owner: group <file/folder>

b. Change file time stamps to the current time


touch <file/folder>

c. View a file
cat <file/folder>

d. Show the disk free space on one or more file systems


df

e. Show how much disk space a directory and all its files contain
du <file/folder>
f. Delete a link
rm <linkname>
unlink <linkname>

4. How to extract the second row of a text file?


head -2 <filename> | tail -1

5. List all the files ending with “a”?


ls *a

6. Change to the home directory of another user directory?


cd /home/usr

7. List all the files in the current directory having “I” as the second letter in their names?
ls ?[i]*

8. List all the files in the current directory having “a” in their names?
ls *a*

9. Remove all the directories which ends with “run” in the present directory?
For empty directories: rmdir *run
For non empty directories: rm -fr *run

10. Remove all the files with extension .cpp?


rm -fr *.cpp

You might also like