Viewing Files

The bootstrap script installed bat, a modern replacement for cat with syntax highlighting and line numbers:

Ubuntu
bat myfile.txt

Other viewing commands:

Command Action
bat file.txt View with syntax highlighting
head -n 20 file.txt View first 20 lines
tail -n 20 file.txt View last 20 lines
tail -f logfile.log Follow file (watch for new lines)
less file.txt Paginated viewing (press q to quit)

Creating Files

Create an empty file

Ubuntu
touch newfile.txt

Create a file with content

Ubuntu
echo "Hello, World!" > hello.txt

Append to a file

Ubuntu
echo "Another line" >> hello.txt
Single vs double arrows

> overwrites the file. >> appends to the end. Be careful with > - it will erase existing content!

Editing Files

The bootstrap script installed Neovim (nvim), a powerful terminal editor. For quick edits, you can also use nano which is simpler:

Ubuntu
nano myfile.txt

In nano:

  • Ctrl+O - Save (Write Out)
  • Ctrl+X - Exit
  • Ctrl+K - Cut line
  • Ctrl+U - Paste

Using Neovim

Ubuntu
nvim myfile.txt

Quick Neovim basics:

  • Press i to enter insert mode (to type)
  • Press Esc to return to normal mode
  • Type :w and press Enter to save
  • Type :q and press Enter to quit
  • Type :wq to save and quit

Copying and Moving

Command Action
cp file.txt backup.txt Copy a file
cp -r folder/ backup/ Copy a directory recursively
mv old.txt new.txt Rename a file
mv file.txt ~/Documents/ Move a file to another directory

Deleting Files

No Recycle Bin!

Linux rm permanently deletes files. There is no recycle bin. Always double-check before deleting.

Command Action
rm file.txt Delete a file
rm -i file.txt Delete with confirmation prompt
rm -r folder/ Delete a directory and contents
rmdir emptyfolder/ Delete an empty directory only

File Permissions

Linux files have permissions controlling who can read, write, and execute them. When you run ls -la, you'll see something like:

Output
-rw-r--r-- 1 john john 1234 Jan 15 10:30 myfile.txt
drwxr-xr-x 2 john john 4096 Jan 15 10:30 myfolder

The first column shows:

  • d - directory (or - for regular file)
  • rwx - owner permissions (read, write, execute)
  • r-x - group permissions
  • r-x - everyone else's permissions

To make a script executable:

Ubuntu
chmod +x script.sh