Command Line Basics Flashcards
How to get help in Linux
-?, -h or -help
grep –help
General syntax for a command Linux ?
command -[switch] parameter
Linux Control Function Keys
Ctrl+c : interrupts a process
Ctrl+z: Pauses a process
fg: Resumes a pauses process
How to graphically display folder and file structures
Use the tree command
command helps us find file in the linux file system.
It is very efficient and fast as it uses indexing databases.
locate
How to update the indexed database manually?
sudo updatedb
What are the Linux file permissions?
■ R for read
■ W for write
■ X for executable
What is chmod used for?
To change file permission
Syntax: chmod [permissions] [file]
use either the alphabets or bits to assign permissions
What command is used to change the ownership of a file?
chown
Syntax : chown root [file] . Use chown root:group [file]
What does the find command do ?
used to find files and doesn’t use indexed database.
take longer but gives but gives real-time outputs of the file locations. It is more robust and reliable.
ex: find path –name ″filename″
grep
It uses pattern based searching.
grep [search] [directory]
grep -a : searches binary files
What’s the linux boot process?
BIOS -> Boot loader (GRUB) -> initrd -> /boot
What is stored in /boot?
Kernel, initial ram disk, other files needed to boot the OS
What is is vmlinux or vmlinuz(compressed) ?
The linux kernel
How to view the kernel boot messages?
dmesg OR /var/log/dmesg
What are the linux runlevels?
0: power off
1: single user mode
2-5: normal system operations
6: reboot
Runlevels are replaced by systemd.
use systemctl command to change targets.
What does linux use for logging?
syslog
How does syslog categorizes messages?
By the use of:
- Facilities (the source of the message)
- Severities (Urgency categorization)
What are the Severity types in syslog?
- emergency
- alert
- critical
- error
- warning
- notice
- info
How does a syslog server process messages?
- syslogd
or rsyslog
or syslog-ng
How to generate your own log messages?
Use the logger utility.
How to automatically prune logfiles and keep your disk from filling with old messages?
Use the logrotate utility
What are the two types of disk partitions?
MBR - Master Boot Record (Max 2TB)
GPT - GUID Partition Table
What are the three disk partition utilities ?
fdisk: Create and modify partitions
gdisk
parted
What tool is used to create file systems?
mkfs
ex: mkfs -t ext4 /dev/sdb2
What is the df command for ?
To show how much disk is in use?
What is the umount command for?
To disconnect a disk from the linux system.
ex: umount /dev/sdb2
What is /etc/fstab used for?
To control what file system gets mounted where and in what order.
How to view the labels and UUIDs of storage devices attached to the system?
Use:
lsblk -f
blkid
How to create disk lables?
e2lable
Where are account information stored?
/etc/passwd and /etc/shadow
What attributes accounts have?
username UID GID Comment home directory shell
How to Create, Delete, Modify accounts?
useradd
userdel
usermod
Where is the group information stored?
/etc/group
How to create, delete, modify a group?
groupadd
groupdel
groupmod
How to view group memberships for accounts?
groups {account}
groups
ex: groups bob
Class A first octet?
1 .0 > 127.0
Class B
128.0 > 191.255
Hosts: 65, 536
Class C
192.0.0 > 233..255.255
Hosts: 255
What is the Private Address Space?
- 0.0.0 - 10.255.255.255
- 16.0.0 - 172.31.255.255
- 168.0.0 - 192.168.255.255
How to display the FQDN?
hostname -f
How to display the hostname?
hostname
or
uname -n
To lookup or resolve an IP or a DNS name?
Use :
host
or
dig
What does the /etc/hosts file contain?
A list of IP addresses and host names
what does /etc/nsswitch.conf file do?
Controls the order in which lookups are performed.
ex: DNS or hosts file first.
How to define if network interfaces use DHCP or Static?
Red Hat: /etc/sysconfig/network-scripts/ifcfg-Device
Ubuntu: /etc/network/interfaces
Shell environment configuration is located?
/etc/profile
How to manually assign IP addresses?
Use ip or ifconfig
ifup/ifdown : to bring up or down an interface
How to see the process running on a system?
ps
How to display a list of jobs?
jobs
How to kill a process or job?
kill PID/job ID
Schedule a task?
cron
How to
■ Make changes to stream of texts?
■ Search and replace text?
sed
Ex: s/old/new/g interpret as string///replace all strings found.
What is sort used for ?
To organize that we get for an output
What is uniq used for?
To remove redundant results
Usually used with
The -c switch is used to count the words
What is used for?
ListOpenFiles
Shows files that are currently being accessed
Display a lot of system usage
Can be used to find files that shouldn’t be open
How to create hidden files in linux?
start the file name with a ( . )
How to create a batch of new users?
Use the command
A batch mode for creating new users.