So I have been daily driving Linux systems on my PCs for a year now, but I still haven’t “learn Linux” systematicly yet, so here I decided to take a course on this, and here are my notes.
Basic Navigations
When we open up a terminal emulator or TTY, we are usually in our home
directory by default.
Print Working Directory
To see the where we are currently, use:
pwd
To See My Username
whoami
or
echo $USER
List File and Directories
Now let’s see what’s in current (or any) directory:
ls <directory>
to see hiddent permissons,timestamps and more info of them, add
-l
flag:ls -l
some distribution may have preconfigured
alias
for it as:ll
to list hidden files, add
-a
flag:ls -la
to list contents of directory and its sub-directories, use
-R
to list recursively:ls -laR
alternatives to ls
:
exa
https://github.com/ogham/exa written in Rustexa is a modern replacement for the venerable file-listing command-line program ls that ships with Unix and Linux operating systems, giving it more features and better defaults. It uses colours to distinguish file types and metadata. It knows about symlinks, extended attributes, and Git.
lsd
https://github.com/Peltoche/lsd written in RustThis project is a rewrite of GNU ls with lot of added features like colors, icons, tree-view, more formatting options etc.
Change Directory
To change to a different directory:
cd <directory path>
In Linux/Unix or macOS, directory/file path can be:
Exact location
cd /home/user0/Documents
Absolute location
# Assume that I am in user0's home directory already cd Documents
.
is the current directory, this following command is the same as abovecd ./Documents
if I am in
/home/user0/Documents/notes
, use..
to go up a directorycd ..
This
~
tilde sign represent current user’s home directorycd ~/Documents
Now that covers the basics of navigation, of course there are more ways such as tree
, but let’s move on for now.