CLOs - Working With Files Flashcards

1
Q

What are basic commands for viewing files and what do they do?

A

cat - viewing files that are not very long, no scroll-back provided
tac - viewing a file backwards, starting with last line
less - viewing larger files, paging program, lets search and navigate within file, scroll-back, space for next page, -N for line numbers
tail - print last 10 lines of file by default, with -n 15 or just -15 changes it to the 15 last lines
head - opposite of tail

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what does command do?
wc

A

Word count gives information about word count, line count etc of file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does this command do?
cat -n

A

Shows file with line numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does this command do?
touch file

A
  • update the access, change and modify times of files
  • by default resets files timestampt to match current time
  • can also be used to create empty files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you create new directories?

A

mkdir sampdir -> creates sample directory named sampdir under current directory

mkdir /usr/sampdir -> creates sample directory under /usr

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you remove an empty directory? Or a directory and all of its contents? How can you do it interactively?

A

rmdir -> empty directory

rm -rf -> recursive

rm -i -> interactively before every removal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does this command do?
mv

A
  • simply rename a file
  • move a file to another location, while possibly changing its name at the same time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly