Introduction
Iâve started following the Linux Upskill Challenge to sharpen my Linux knowledge and hands-on skills. Itâs a series of 21 lessons designed to be completed daily, but Iâll be going through them at my own pace. Iâll share my journey and notes here as I move forward.
Day 2 - Basic navigation
- URL: https://linuxupskillchallenge.org/02/
- Previous Lesson: My Linux Upskill Challenge: Day 1
RTFM
- In this lesson, I learned a new acronym: RTFM â âRead the F***ing Manual.â đ
- When youâre learning and using Linux (or anything else) and have questions, of course, youâre always free to Google it or ask ChatGPT.
- However, the best system administrators are those who first RTFM.
This is something weâre starting to forget nowadays!
- Linux systems offer several ways to access documentation. But ifâafter searchingâyou still need help, you can always ask a well-written question in forums, Reddit, Discord, or other communities.
I think this is even more relevant today, especially when writing good prompts in the âGPT era.â
Looking for Documentation
-
The
man
command is a great place to startâmost installed applications have their own manual. -
For instance, you can find the manual for these commands:
man cp
man mv
man grep
man ls
- even
man man
đ
-
That said,
man
output can be overwhelming for some commands or too minimal for others. Thatâs wheretldr
comes inâit provides simplified, community-written man pages for common Linux (and other OS) commands.
tldr
is another tool for viewing documentation. I installed it usingsudo apt install tldr
, but it didnât work right away on my EC2 instance.- I got the following error:
tldr: /home/ubuntu/.local/share/tldr: createDirectory: does not exist (No such file or directory)
- I fixed it with these two commands:
mkdir -p ~/.local/share/tldr
tldr --update
- The second command pulls the latest pages from the official GitHub repo (make sure your server has internet access!).
- I tried
tldr
with the same commands as before, and yesâit showed me much more simplified info.
- I also learned about the
apropos
command, which is equivalent toman -k
. - Both are useful when you kind of know what a command does and want to search for keywords in the manual.
- For example, if you search for the phrase âremove fileâ using
apropos "remove file"
, youâll get results like this:
ubuntu@ip-172-31-92-220:~$ apropos "remove file"
git-rm (1) - Remove files from the working tree and from the index
rm (1) - remove files or directories
ubuntu@ip-172-31-92-220:~$ man -k "remove file"
git-rm (1) - Remove files from the working tree and from the index
rm (1) - remove files or directories
-
Some commandsâespecially shell built-insâdonât have
man
pages. -
For those, you can use the
help
command instead. -
Example: use
help export
instead ofman export
. -
I found exceptions like
echo
, which works with bothman echo
andhelp echo
. -
The best way to check if a command is a shell built-in is to use the
type
command.
- Lastly, thereâs the
info
command. It gives more detailed documentation, sometimes written in a tutorial style and with hypertext navigation.
Navigate the File Structure
-
I discovered a command that gives you documentation about the Linux file system:
man hier
. -
/
is the top-level directory (called root) for all other folders. -
đ§ To find out where you are in the file system, use
pwd
âthis is like your GPS in Linux. đ° -
By default, youâll start in the
/home/<user>
directory, unless youâre logged in asroot
, in which case youâll be in/root
. -
You can move between directories using
cd
:cd ..
takes you âupâ one level.cd .
keeps you in the same folder. đ€
-
You can use either relative or absolute paths to move around:
- For example, if you first do
cd /var
, then bothcd log
andcd /var/log
will get you to the same place.
- For example, if you first do
-
Just running
cd
returns you to your home directory, as doescd ~
. -
You can also use
~
as a shortcut to move into folders inside your home directory from anywhere.- For instance, if youâre in
/var/log
and want to go to/home/ubuntu/data/example
, just usecd ~/data/example
.
- For instance, if youâre in
ubuntu@ip-172-31-92-220:/var/log$ cd ~/data/example/
ubuntu@ip-172-31-92-220:~/data/example$
Listing Files in a Folder
-
I used
ls
with different options (âswitchesâ) to list files.
For example:ls
,ls -l -L
, andls -l -t -r -a
(or justls -ltra
). -
Files or folders that start with a
.
are hidden. Usels -a
to see them. -
You can combine switches and provide a folder path:
e.g.,ls -ltra /var/log
-
Entries that start with
d
are directories. -
Some terminals show these in a different colorâif not, try
--color=auto
.
ubuntu@ip-172-31-92-220:~/data/example$ ls -ltra /var/log
...
Basic Directory Manipulation
- I created a new folder with
mkdir test
, then moved into it withcd test
. - You can repeat this to build nested folder structures.
mkdir test
cd test
- To move a folder into another directory, I used
mv
: - Created a folder
test2
, then movedexample
fromtest
totest2
.
mv test/example test2
- To remove an empty directory, use
rmdir
. - To remove a non-empty one, use
rm -r
.
Basic File Manipulation
- To create a new (empty) file:
touch newfile.txt
- To move it:
mv newfile.txt test2
- To delete it:
rm
touch newfile.txt
mv newfile.txt test2
rm test2/newfile.txt
A Bit More Advanced Directory Navigation (Stack-Based)
- I learned about
pushd
andpopd
, which let you move between folders using a stack (LIFO order). - Itâs different from
cd ..
âwithpushd
you can hop to/etc
, then/var/log
, and then jump back in reverse order usingpopd
. - Use
dirs
to see the current directory stack.
pushd /etc
pushd /var/log
dirs
popd
popd
- If you run
pushd
without arguments, it swaps your current and previous directoriesâsimilar tocd -
, but it remembers your path history.
So these are my notes for the Day 2 â Basic Navigation of the Linux Upskill Challenge.
Additional Resources
- Difference between help, info and man command
- GNU Texinfo
- Explore the Linux File System
- Linux File System â YouTube
- Simple Terminal Commands on Ubuntu â YouTube
- Solaris Unix Commands