- ls
stands for “list” lists the contents of a directory
- ls -l
long listing format gives additional info of files, size, date of last exist….
- ls -lh
long listing format + print human readable format
- ls -lSh
sorted by the size and then by the date of exist time
ls [another directory]
cd
change directory
- pwd
print whole pathname of current directory
- du
displays the disk space used by files
- df
reports amounts of available disk space being used by file systems
- man: manual
view system’s manuals
- mkdir
make directory
- cp
makes copies of files cp SOURCE DIRECTORY
cp -r
copy a whole objects in a directory or folder recursively
- mv
move or rename files
mv SOURCE DIRECTORY
- touch
change file timestamp
- cat
displays the contents of a file copies or appends text files into document
- head
prints the first part of files default is 10 lines, so we can specify the number by adding like -4 between command and file and then display 4 lines
- tail
prints last part of files
- more
preview content without reading whole file and loading it into memory
- less
displays text, allowing scrolling
- wc
“word count” prints count of lines
- grep
“global regular expression print” process text and prints any lines which match a specified pattern
grep PATTERN FILE
- cut
drops sections of each line of a file
cut FILE
cut -d " " -f1 FILE // set the space symbol as delimiter and print out first field of file
- tr
translate one set of character to another (replace)
tr [-Ccsu] str1 str2
cat file.txt | tr ' ' '.'
- sort
sorts the content
- awk
interpreted programming language text processing
Operators
- >
overwrites the file with the content if it exists or creates it if not exists
- >>
appends to a file
- |
pipe operator, output of first command acts as an input to the second command
Commands for processes managing
- free
displays total amount of free and used memory
> free -g # print file sizes in gigabytes
- top
provides a dynamic real-time view of a running system