Introduction
This is my journal note following the Linux Upskill Challenge: Day 5.
📄 more
and less
Commands
-
more
is a command that lets you view text files one page at a time. You pressspace
to go to the next page. When you get to the end of the file, you cannot go back. -
less
is similar but more powerful — you can scroll up and down with the arrow keys and search inside the file with/
.- You can go to the beginning of the file with
g
, and to the end of the file withG
. - You can access help with
h
. - You exit the file with
q
. less
doesn’t load the entire file into memory, so it’s great for viewing large files.
- You can go to the beginning of the file with
-
Example of use:
more /etc/services
less /etc/services
I experimented with these two commands that allow you to view the contents of text files. Certainly, they work in different ways. I think the winner is
less
, which is more flexible, but I imagine there are still situations wheremore
does the job.
🧠 Tab Completion in Linux
- Tab completion lets you press
Tab
to auto-complete commands, file names, or paths. - This is a feature provided by the shell: bash, zsh, and fish all support tab completion.
- If there’s ambiguity (multiple matches), pressing
Tab
twice shows a list of possibilities. - Works with commands, paths, directories, users, etc.
- Saves time and avoids typing errors.
I’m not good at memorizing commands, so this is definitely very useful when working in the command line.
⏳ The history
Command
- The
history
command shows a list of previously run commands with line numbers.
history
history
is a built-in shell command.
- If you want to see, for instance, just the last 10 commands, you can type:
history 10
This works well in the
bash
shell.
- Here’s a clever trick to navigate the history output:
history | less
- This uses a pipe (
|
) to pass the output ofhistory
as input to theless
command.
It’s a great example of the UNIX philosophy: “using small tools that work together by chaining them.”
🔁 Repeating Commands
- You can repeat a command from history using
!<line-number>
, for example:
!102
When you re-run a command with
!number
, it moves to the end of the history queue with a new number, and the original number is overwritten.
- You can also re-run the last command with:
!!
- Let’s say you submit a command that requires
sudo
but you forgot. Instead of retyping the entire command withsudo
, you can just do:
less /etc/shadow
/etc/shadow: Permission denied
sudo !!
sudo less /etc/shadow
🔍 Search Command History with Ctrl + r
- Press
Ctrl + r
to start a reverse search through your history. - Start typing part of a command, and it will autocomplete the most recent match.
- Press
Ctrl + r
again to go further back, orEnter
to run it.
🕵️ Hidden Files (Dot Files)
- Hidden files in Linux start with a dot (
.
), so they’re often called dot files. - You list them with:
ls -la
- Or:
ls -ltra
- Common dot files include
.bashrc
,.bash_profile
,.bash_history
,.ssh/
, etc. - These files store personal configurations in your home directory.
📂 Exploring Dot Files
- I used
less
to read the contents of dot files:
less ~/.bashrc
less ~/.bash_history
✏️ Editing with nano
nano
is one of the most widely used text editors in Linux because of its ease of use.- I used
nano
to create a new file with a summary of the first 4 lessons.
Example:
nano lessons_summary.txt
I was already familiar with the basic functions of
nano
, but I’ll need to explore more advanced features later.
🐚 Switching Shells: bash
, zsh
, fish
-
Linux supports multiple shell programs beyond just
bash
. -
I tried out:
zsh
: very popular with advanced users.fish
: user-friendly, with autocomplete and syntax highlighting out of the box.oh-my-zsh
: A popular framework for managing Zsh configuration, which adds plugins and themes easily.
-
I wrote a separate note to describe the process of installing and switching shells:
🧩 Terminal Multiplexers: screen
and tmux
A terminal multiplexer is a command-line tool that lets you run and manage multiple terminal sessions within a single terminal window or SSH connection — and keep them running even if you disconnect.
screen
screen
is a tool that lets you have multiple shell sessions on a server and leave them “in the background” while you work on something else.- You can even log out of your server and get back to where you left off in a session.
I confess it was hard to get it the first time, but after watching a YouTube video and asking ChatGPT, I kind of got it. I’ll put the references at the end of the note.
tmux
tmux
is a modern and more versatile alternative to screen
. It allows you to organize your terminal into sessions, windows, and panes, making it super handy for multitasking, remote work, and persistent workflows. Once you get used to it, it’s hard to go back.
I wrote a separate note with a quick introduction to tmux basics:
Related Notes
- Previous Lesson: My Linux Upskill Challenge: Day 4
- Next Lesson: My Linux Upskill Challenge: Day 6
External Resources
- Unix Less Command: 10 Tips for Effective Navigation
- How To Use Bash History Commands and Expansions…
- BASH Shell commands less
- Tab completion
- What are dotfiles?
- Nano editor tutorials
- Bash Shell: Take Control of PS1, PS2, PS3, PS4 and PROMPT_COMMAND
- Bash Shell PS1: 10 Examples to Make Your Linux Prompt like Angelina Jolie
- Video: How to Use the Linux Screen Tool