Utilize Bash commands (file management, directory navigation, and environmental variables)

📘Cisco DevNet Associate (200-901 DEVASC)


1. Bash Commands for Directory Navigation

In Linux or macOS (and Windows via WSL or Git Bash), Bash is a command-line shell used to interact with the operating system. One common task is navigating directories (folders).

Important Commands

CommandDescriptionExample
pwdPrint Working Directory – shows your current location in the file system$ pwd/home/user/projects
lsList files and folders in the current directory$ lsapp.py config/ README.md
ls -lLists files with details like permissions, owner, size, date$ ls -l → shows a table with details
cd <directory>Change directory$ cd projects moves into the projects folder
cd ..Move up one directory levelIf in /home/user/projects, $ cd ../home/user
cd ~ or just cdGo to home directory$ cd ~/home/user
treeShows the directory structure visually (may need sudo apt install tree)$ tree → shows nested files/folders

Tip for exams: Understand the difference between absolute paths (/home/user/projects) and relative paths (../projects).


2. Bash Commands for File Management

Managing files is essential in development environments. Here are the key commands:

CommandDescriptionExample
touch <filename>Create an empty file$ touch test.txt → creates test.txt
mkdir <dirname>Create a new folder$ mkdir logs → creates logs folder
cp <source> <destination>Copy file or folder$ cp test.txt backup.txt → copy file
$ cp -r logs backup_logs → copy folder recursively
mv <source> <destination>Move or rename a file/folder$ mv test.txt old_test.txt → rename
$ mv test.txt ../ → move to parent directory
rm <filename>Remove (delete) a file$ rm old_test.txt
rm -r <dirname>Remove a folder and its contents$ rm -r logs
cat <filename>Display the content of a file$ cat config.txt → shows file content
less <filename>View content of a file page by page$ less config.txt
head <filename>Show first 10 lines$ head config.txt
tail <filename>Show last 10 lines$ tail log.txt
nano <filename>Open a file in a simple text editor$ nano config.txt

Tip for exams: Know when to use -r (recursive) and the difference between mv and cp.


3. Bash Commands for Environmental Variables

Environmental variables store information that programs or scripts use. For example, they can store user information, system paths, or configuration values.

Key Commands

CommandDescriptionExample
echo $VAR_NAMEDisplay the value of an environment variable$ echo $HOME/home/user
export VAR_NAME=valueSet a temporary environment variable$ export PROJECT_DIR=/home/user/projects
env or printenvShow all environment variables$ env → displays HOME, PATH, etc.
unset VAR_NAMERemove an environment variable$ unset PROJECT_DIR
PATH variableStores directories to search for executable programs$ echo $PATH/usr/local/bin:/usr/bin:/bin

Tip for exams: Know that environment variables can be temporary (only for the session) or permanent (set in .bashrc or .bash_profile).


4. Real-Life IT Example Usage

In a DevOps or software development environment:

  • Directory navigation: Move between project folders to edit code or view logs.
  • File management: Create configuration files (config.yaml), move logs to backups, or delete temporary files.
  • Environment variables: Store API keys or project paths temporarily for scripts without hardcoding them in the code.

Example:

export API_KEY=abc123
echo $API_KEY
python app.py
unset API_KEY

This ensures sensitive information is not saved permanently on the system.


5. Exam Tips for 200-901 DEVASC

  1. Be able to list, navigate, and manipulate files and directories using the basic commands.
  2. Understand relative vs absolute paths.
  3. Know how to set, view, and remove environment variables.
  4. Remember ls, cd, mkdir, rm, cp, mv, touch, export, echo — these are frequently tested.
  5. Practice using the terminal because hands-on knowledge makes it easier to answer scenario-based questions.
Buy Me a Coffee