To perform these tasks, you can use the following Linux commands:
1. Create a text file with 30 lines:
```bash
echo -e "Line 1\nLine 2\n...\nLine 30" > mytextfile.txt
```
2. Display the first 5 and last 5 lines:
```bash
echo "Displaying first 5 lines:"
head -n 5 mytextfile.txt
echo -e "\nDisplaying last 5 lines:"
tail -n 5 mytextfile.txt
```
3. Count the number of times the word "has" appears:
```bash
grep -o -i "has" mytextfile.txt | wc -l
```
4. Display file permissions:
```bash
ls -l mytextfile.txt
```
5. Change file permissions to rwx------:
```bash
chmod 700 mytextfile.txt
```
Make sure to replace "mytextfile.txt" with the actual name of your text file.
These commands create a text file, display its content, count occurrences of the word "has," display file permissions, and then change the permissions to rwx------. Adjust the file name accordingly.
0 टिप्पणियाँ:
Post a Comment