Working at the Command Line Flashcards
[cmd] pwd
print working directory - outputs the current directory that you’re in
[cmd] tty
prints the file name (because everything in linux is a file) of the terminal connected to the standard input. IE your current terminal.
Physical Terminal = tty1
Pusdo Terminal = pts/0
[cmd] who
Tells you who is logged onto the system.
[cmd] exit
logs you out of the current terminal.
[cmd] ip a s
(aka ip addr show)
prints all the current network interfaces and their IP information.
~
indicates the home directory
[cmd] ls
lists (non-hidden) files and directories in your current working dir.
NOTE: ls is aliased by default to ‘ls –color=auto”.
[cmd] ls -a
lists all files including hidden files.
[cmd] ls -F
shows the file type in the printed output. So dir files end in a / and symbolic links end in an @ and executables end in * — useful if your terminal doesnt support colors
/etc
this dir contains all the system/service configuration files.
configuration file
local file used to control the operation of a program but is static and cannot be an executable binary.
[cmd] ls -l
gives us a long listing of file types with metadata, which includes file type - permissions block - number of hard links - owner - group owner - size - date modified - name
[cmd] ls -r
reverses the order of the printed output
[cmd] ls -lrt
prints the long version, and reverses it based on time. Prints files but reversed based on time, so the oldest file will be listed first. (you can replace t with o to sort by owner)
[cmd] ls -h
puts the file size in a human readable format
[cmd] ls -d
lists the dir itself instead of the contents of the directory.
[cmd] $(cmd)
ie: ls -l $(tty)
anytime you put $() the command line will run the cmd in ()s first and then the output of that is used as the input of the other cmd.
[cmd] lsblk
lists the block devices (partitions) on the system. (which because everything is a file, these exist in the dev dir also)