Week 2 + 3 Flashcards
(38 cards)
What do the commands below do?
tilda (~) command?
whoamii command?
pwd command?
cd command?
tilda(~) goes to the home directory
whoami checks who the user is
pwd checks the current working directory(where u are)
cd command changes directory listed after cd
What are Paths?
Types of Paths?
List of directories separated by /.
example: /home/tenzing/desktop
Types: Absolute(starts with /), and Relative
Differences with Absolute and Relative paths?
Absolute: starts with / root directory
Relative: starts at current directory. use .. to go back a directory or ../../
What does ls -a command do?
what does ls -l command do?
Shows all hidden files and folders, hidden folders will have a . in front
Gives a long list with detailed info.
1st Column: File type and access
permissions
* 2nd Column: # of HardLinks to the
File
* 3rd Column: Owner and the
creator of the file
* 4th Column: Group of the owner
In the ls -l command
The first character on each line indicates the type.
List the types:
d (directory)
- (regui]lar file)
l (symbolic link)
s (socket)
p (pipe)
b (block file)
c (character file)
drwxr-xr-x
define this
d(type)
rwx(read-write-execute for owner)
xr(perms for group)
x(perms for others)
r = read
x = execute
w = write
What does -h command do?
And describe human-readable format?
when file size too big makes it easier to read. M - megabytes, G - Gigabytes, T- Terabytes.
What are different ways to sort with ls command?
ls -r (recursive, sort backwards)
ls -s (sort by file size)
ls -t (sort by time)
How to use ls to get a detailed timestamp?
ls –full-time
How to get to the manual page on how to use glob?
man 7 glob
What does the asterisk(*) do? and uses?
- represents any name
d - name that ends with d
a - name that starts with a
c - name that contains c
a*c - name that starts w/ a and ends w/ c
- represents any name
What does the ? character do?
??? - names that contain 3 characters
d.??? - name that starts with d. then contains any 3 characters
What does the square brackets do
[ ]?
[abc]d - begins with either a, b, or c and ends with d.
[a-zA-Z][0-9] - begins with any letter lower or uppercase and ends with any number from 0-9
What does [!] do?
[!abc]d – this is a name that does NOT begin with either character ‘a’
or ‘b’ or ‘c’ and ends with character ‘d’
What do the curly brackets do?
Curly brackets {} are used to specify terms that are separated by commas and each term must be a name or a wildcard.
Same as IN (value1, value2) in DBAS
How to create text files?
touch newfile.txt
or
cat > newfile.txt
content
content
CTRL-D to save
How to create directory?
and
How to create 3 directories at once? named ‘a’, ‘b’, ‘c’
mkdir directoryname
mkdir a b c
Create a two parents(o and s)
and s has two children
mkdir -p o/p/q/r s/{sub1,sub2}
How to remove directories and files?
rmdir to remove directory
rm filename or
rm -r filename to force delete
How to copy and move files and directories?
copy files:
cp filename end location
copy directory:
cp -r directoryname endlocation
move files:
mv filename endlocation
Use -n for no clobber, to prevent cp and mv commands from overwriting content at the destination
How to rename files or directories?
rename directory ‘a’ to ‘aaa’ and move ‘aaa’ to ‘b’
mv directory newname
mv a b/aaa
Types of text editors?
nano and vim
Explain the difference between single hypen(-l) and double hyphen?
Single hypen options are for short form (-h), while double hypen are for full words (–human-readable).
How to check for history?
history command