Linux Commands Flashcards
what is cmd to clear the screen in terminal?
clear (short cut: Ctrl + L)
What is the cmd to show the current working directory?
pwd
What is the cmd to list the folders of the current directory?
ls
what is the cmd to list all the processes currently running?
ps
What is the cmd to get the operation system which is currently running?
uname
What is the cmd to end the terminal / shell?
exit (shortcut : Ctrl + d)
what does command “ls- a” do?
Will list all hidden files which start with a “.”
what does command “ls- l” do?
List the list of visible files in a long format
what command is used to access the help manuals built in?
man <option> <command></command></option>
What is the File System Hierarchy Standard which is currently used?
FHS 3.0 released on June 03, 2015
What is the file system structure
Level 0 - root (/)
Level 1 - sbin , media, bin, etc(apt),home(lenin,Desktop, Documnents, Downloads, Pictures, MyCode), tmp, user(bin, sbin,share),lib, var,mnt
File System: traversing the tree
/ is the root of the file system
/ is also the delimiter for sub-directories
. is current directory
.. is parent directory
path for traversal can be absolute or relative
What are the components of typical output of ls -l ?
drwxr -xr -x 5 gphani gphani 12288 Nov 25 10:00 Documents
here “d” denotes file type , here it is directory
rwx (owner permissions)
r-x (Group permissions, - denotes no permission)
r -x (Others permissions)
5 - Number of hard links
gphani - owner
gphani - group (by default there is a group in every user name)
12288 - size
Nov 25 10:00 - Last modified timestamp
Documents - filename
in ls -l format , what does the file descriptor say?
L stands for link to a different directory( like a shortcut)
D stands for directory
- symbolizes regular file
d symbolizes Directory
l symbolizes symbolic link
c symbolizes character file
b symbolizes block file
s symbolizes socket file
p symbolizes Named pipe
C stands for character file which could be read
B stands for Block devices like HDD where data will be read/written in blocks. Typical linux block size is 1Kb
What is an inode?
ls -i <name>
An entry in the filesystem table about the location in storage media
Each unique file will have a unique inode.
If there are multiple entries for the same inode then they are called hard links</name>
What is a hard link?
how to go back to our user root directory
by typing command cd without any arguments.
What does the file system directories contain?
/bin - Essential cmd binaries (could be a link to /usr/bin)
/boot - static files of the boot loader
/dev - device files (Every device in linux is a file)
/etc - host specific system configuration
/lib - essential shared libraries and kernel modules
/media - mount points for removable devices
/mnt -mount points
/opt - Add on application software packages
/run - Data relevant to running processes
/sbin - Essential system binaries
/srv - Data for services (eg. FTP, HTTP services)
/tmp - Temperory files
/usr - secondary hierarchy (shareable user directory)
/var - variable data (log files)
What are the various directories in /usr hierarchy?
/usr/bin - User Commands (all available commands for user)
/usr/lib - Libraries (user specific libraries, may not be available for other users)
/usr/local - Local hierarchy
/usr/sbin - Non-vital system binaries
/usr/share - Architecture dependent data
/usr/include - Header files included by C programs
/usr/src - Source code of various installed applications
What are the various directories in /var hierarchy?
/var/cache - Application cache data
/var/lib - variable state information
/var/local - variable data for /usr/local
/var/lock - lock files
/var/log - log files and directories
/var/run - data relevant to running processes
/var/tmp - temperory files preserved between reboots
What is the difference between a sharable folder vs an unshareable folder?
sharable - a file system that could be shared with many computers to converse storage and uniform file system.
Vs Unshareable.
static shareable - /usr, /opt
static unshareable - /etc, /boot
variable sharable - /var/mail
variable unshareable -/var/run, /var/lock
what does the date command do?
displays current date and time (as set in local computer)
date -R (email format, 24 hr format with GMT)
How to display the dates a file was edited?
date –f <file></file>
What does the command cal do?
displays the calender
cmd “ncal” displays calender in different orientation than that of the command “cal”.. ie., transposes the output of the command “cal”
What does the command “free” do?
displays memory statistics
free -h (displays in human readable format)clerar
What does the command “groups” do?
displays groups to which user belongs
what does the command “file” do?
displays the type of file
How to display all the file types in a particular directory?
file *
what does command “cd -“ do?
Takes us to the previous directory we were in
what does command “cd ~” do?
Take us to home directory .. just like command “cd”
. is shortcut for current directory
.. is shortcut for parent directory
- is shortcut for previous directory
~ is shortcut for home directory
how to create multiple directories at the same time?
mkdir dir1 dir2
how to delete a directory?
rmdir dir1
The rmdir or rm -d command is for removing empty directories, while the rm -r command deletes non-empty directories.
Which command will give information on open network ports on the machine?
netstat
what does command wget do?
Wget is a command-line tool that makes it possible to download files from the internet directly to your active directory. It operates in the background, allowing tasks to continue even if you’re offline. The name is a combination of World Wide Web and the word get. It supports downloads via FTP, SFTP, HTTP, and HTTPS