Day 2: Linux Basic Commands

CloudDevOpsHub Batch 45 | Guided by Vikas Ratnawat Sir

1. Understand your terminal

whoami
pwd
date
hostname

2. List and navigate directories

ls
ls -l
ls -la
cd /var/log
pwd
cd ~
cd ..

ls lists files; -l shows detailed information; -a includes hidden entries. cd changes the current directory.

3. Create files and directories

mkdir practice
cd practice
touch notes.txt
ls -l
cat notes.txt
echo "My Linux practice" > notes.txt
cat notes.txt

mkdir creates a directory, touch creates an empty file when it does not exist, and cat displays file contents. The > operator replaces the file's existing contents, so use it carefully.

4. Copy, move and remove

cp notes.txt notes-backup.txt
mv notes-backup.txt revised-notes.txt
ls -l
mkdir archive
mv revised-notes.txt archive/
ls archive

Practise these commands only inside your own practice directory. Use rm carefully because deleting files may be irreversible.

5. Processes

ps
ps aux
top

ps displays process information. ps aux shows a broader process listing, and top provides a live process view; press q to quit.

Revision Questions

  1. What is the difference between pwd and ls?
  2. How do you list hidden files?
  3. How can you create an empty file?
  4. What information does ps show?