Linux Directory Structure and Basic
Commands
Command Line Interface
• Terminal for your computer
• Enable users to interact with the operating system
• Takes in commands, and passes them on to the computer's operating system
• Output shows the reply from the operating system
Linux Directory Structure
Directory Description
/ "root" Primary hierarchy for entire file system
/bin Essential command binaries must be available in the
single-user mode for all users. e.g cat, ls
/boot boot loader files, e.g kernels, initrd
/dev device files, e.g /dev/sda
/etc Editable text configuration or Extended tool chest
Linux Directory Structure
Directory Description
/etc/opt Configuration files for add-on packages stored in /opt
Users' home directories, containing personal files,
/home personal settings etc.
/lib Essential libraries for binaries in /bin and /sbin
/media mount point for removable media such as usb
/mnt Temporarily mounted filesystems
Linux Directory Structure
Directory Description
/opt Optional application software packages
/proc Virtual fs providing process and kernel as files
/root Home directory for root user
/run runtime variable data, currently logged-in users,
running daemons etc.
/sbin Essential system binaries e.g fsck, init, route
Linux Directory Structure
Directory Description
information about devices, drivers, and some kernel
/sys features
/tmp Temporary files, not preserved between reboot,
severely size restricted
/usr secondary hierarchy for read-only user data, majority
of user utilities and applications
/usr/bin Non-essential command binaries, for all users
/usr/include Standard include files
Linux Directory Structure
Directory Description
/usr/lib libraries for binaries in /usr/bin and /usr/sbin
/usr/local Tertiary hierarchy for local data, specific to this host
/usr/sbin non-essential system binaries
/usr/share Architecture independent data
/var Variable Files
Linux Directory Structure
Directory Description
/var/lock Lock files. keeping track of resources currently in use
/var/tmp temporary files to be preserved between reboots
State information. Persistent data modified by
/var/lib programs as they run e.g databases
/var/log Log Files, Various logs
/var/run Runtime variable data
Linux Basic Commands
• pwd: present working directory.
Linux Basic Commands
• ls: list the files in a directory.
Linux Basic Commands
• mkdir: make directory.
Linux Basic Commands
• cd: to change directory, us 'cd' command
Linux Basic Commands
• touch: Update the last-modified date on the given
FILEs. commonly used for creating a new empty file.
Linux Basic Commands
• vi: screen-oriented text editor.
Linux Basic Commands
• nano: text editor.
Linux Basic Commands
• echo: display line of text/string.
Linux Basic Commands
• echo: write a line into a file using echo, write the
command as
text > filename
Linux Basic Commands
• cat: Concatenate files and print on the standard
output.
Linux Basic Commands
• cat:
⚬ replace the content of a file with another file's
content
■ (source > dest)
⚬ append the content of a file in another file
■ (source >> dest)
Linux Basic Commands
• head: output start of a file.
Linux Basic Commands
• tail: output end of a file.
Linux Basic Commands
• grep: search for a string of characters in a specified
file.
Linux Basic Commands
• rm: removes each file specified.
Linux Basic Commands
• cp: copying files and directories to another location.
Linux Basic Commands
• mv: move file or directory from one place to another.
Linux Basic Commands
• env: print a list of the current environment variables.
Linux Basic Commands
• rmdir: Remove the DIRECTORY, if it is empty.
Linux Basic Commands
• whoami: Print the current user name.
Linux Basic Commands
• find: Search for files in a directory hierarchy
Linux Basic Commands
• sleep : Delay for a specified amount of time
Linux Basic Commands
• dd : Copy a file, converting and formatting.
Linux Basic Commands
• ping: Send ICMP ECHO_REQUEST to network hosts
Linux Basic Commands
• wget: Retrieve files via HTTP or FTP
Linux Basic Commands
• hostname: Get or set hostname or DNS domain name
Linux Basic Commands
• man: interface to the on-line reference manuals