For Legend look here
Files in Linux/Unix
Unix systems have a generell principle, that everything is a file.
And therefore somewhere in the directory structure.
To apply this concept to several different things in a computer, unix has
several different file types:
- Normal files
- Directories
- Links
- Pipes
- Sockets
- Device Files (Block / Character files)
- Door File
Working with Files
In unix systems, a file does not necessarily need a Filetype Extension.
# Have a file to do something with:
curl http://metaphorpsum.com/paragraphs/10/5 > lorem_ipsum.txt
-
Create files:
-
Empty file:
touch test
-
With some content:
echo This text will be the content > test
-
-
Delete files:
-
Single file:
rm test
-
Multiple files:
rm test_file another_file some_other_file
-
File that match a pattern:
rm *_file # deletes all files with names that end with
_file
-
-
Output contents of file:
-
All content at once:
cat
-
Content in scrollable view:
less
-
(Only if installed) Syntax highlighted scrollable:
bat
-
Get only first 10 lines:
head
-
Get only last 10 lines:
tail
-
Get all newly written lines of a file:
tail -f
# Hint: Usefull to have a continues look at **Log-Files**
-
-
Information about content of files:
- Get type of file (works also with directories):
file
- Count words:
wc -w
- Count lines:
wc -l
- Count bytes:
wc -c
- Get type of file (works also with directories):