Skip to content

Latest commit

 

History

History
253 lines (172 loc) · 4.83 KB

presentation-basic-GNU-linux-commands.md

File metadata and controls

253 lines (172 loc) · 4.83 KB
marp paginate color backgroundColor header footer author
true
true
![width:100px height:100px](./img/logo.png)
**20/10/2021 - AnthonyF**
AnthonyF
<style> section { font-family: 'Century Gothic', serif !important; } </style>

Basic GNU/Linux commands

width:300px


Table of Contents

  • Navigation in a shell
  • Files and directories
  • Writing and displaying

FHS (Filesytem Hierarchy Standard)

FHS is a directory structure used by every Linux distros. More info


Navigation in a shell


ls

List directory contents.

GNU coreutils, (1) General commands


Useful options with ls

Arguments Description
-l More information in list format.
-a Hidden files.
-R Recursive, list files in sub-directories.
-lSh Sort by size with human readable.
-i Inodes.
-n Numeric UID and GID.

cd

Change the working directory.

Built in shell command, no proper man type cd help cd man builtins


Useful commands with cd

Commands Description
cd .. Go to parrent directory.
cd - Go back to the previous working directory
cd or cd ~ Go the home directory.

pwd

Print name of current working directory.

GNU coreutils, (1) General commands


Files and directories


mkdir

Create/make directories. Usage : mkdir directory

GNU coreutiles, (1) General commands


Useful options with mkdir

Options Description
-p Create parents directories if don't exist.

rm

Remove files or directories.

GNU coreutils, (1) General commands


Useful options with rm

Options Description
-i Alert before every removal.
-d Remove only empty directory.
-r Remove directories and their contents recursively.

cp

Copy files and directories. Usage : cp source destination

GNU coreutils, (1) General commands


Useful options with cp

Options Description
-d No deference, preserve links.
-r Copy recursively.
-a Same as -dr.

mv

Move or rename files and directories.

GNU coreutils, (1) General commands


Writing and displaying


touch

Change file timestamps. Can also create an empty file.

GNU coreutils, (1) General commands


cat

Concatenate files and print on the standard output. Can also create and write in files.

GNU coreutils, (1) General commands


Read a file

cat file

Write in a file

cat > file

Stop writing with Ctrl + c

Add in a file

cat >> file


Bonus "Here document"

cat > file << EOF


head

Output the first part of files.

GNU coreutils, (1) General commands


Useful options with head

Options Description
-n NUM Print the first NUM lines.
-n -NUM Print all but not the last NUM lines.

tail

Output the last part of files.

GNU coreutils, (1) General commands


Useful options with tail

Options Description
-n NUM Print the last NUM lines.
-n +NUM Print starting at line NUM.
-f Output appended data as the file grows.

Thank you !