File Operations and Permissions
2.1 Creating and Examining Files
Required location: ~/linux_tutorial
Make sure you're in the right directory:
cd ~/linux_tutorial
pwd # Should show your path ending with /linux_tutorial
Create a text file:
touch sample.txt
Create a file with content:
echo "Hello, Linux World!" > sample.txt
View file contents:
cat sample.txt
2.2 Understanding File Details and Permissions
List files with detailed information:
ls -l sample.txt
You'll see output like:
-rw-r--r-- 1 username groupname 19 Jun 20 10:30 sample.txt
Understanding the permission string (-rw-r--r--):
- First character: File type (- = regular file, d = directory)
- Next 9 characters: Permissions in groups of 3
- Characters 2-4: Owner permissions (rwx)
- Characters 5-7: Group permissions (rwx)
- Characters 8-10: Other permissions (rwx)
Permission meanings:
r(read): Can view file contentsw(write): Can modify file contentsx(execute): Can run file as a program
2.3 File Operations
Current location: ~/linux_tutorial
Copy the file:
cp sample.txt sample_copy.txt
Rename the copied file:
mv sample_copy.txt renamed_sample.txt
Move the file to the documents directory:
mv renamed_sample.txt documents/
Verify the move:
ls documents/