Linux Basics Part 1
Linux Basics Part 1
LINUX
COMMANDS
1
by: https://www.linkedin.com/in/natalia-szczepanek/
LIST OF COMMANDS:
• cd • rm • chmod
• ls • tar • passwd
• cp • diff • top/htop
• mv • sort • history
2
W H AT I S A N D W H Y L I N U X ?
• Open Source Operating System (OS)
• Over 1000 commands, but I will present you 30 the most common in daily basis
• I highly recommend to learn at least basics of it, your life will be easier and you’ll be
able to automate a lot of tasks!
3
cd DIRECTORY
• Change directory from your current position
• cd ../ move one directory up, can be used multiple time, for example cd ../../../
• cd- move to previously used directory
4
cat [OPTION]… FILE/S…
• Display content of file/s on the standard output
• Examples:
• It is often used in shell scripting to display messages, debug scripts, or generate dynamic
output
• Examples:
– echo "Hello, world!” : print “Hello, world” in the terminal
– name="John”
echo "My name is $name” : print “My name is John” in the terminal
– echo "This is a new line.\nThis is a tab:\t\tAnd this is a backslash: \\”
• The use of escape sequences such as \n and \t with the echo command is necessary to format
and control the output by inserting new lines, tabs, and other special characters for improved
readability and presentation.
6
man COMMAND
• man is an interface to the on-line reference manuals, it is used to display the manual
pages (documentation) for various commands, programs, and system functions
• It provides detailed information about command usage, options, syntax, and examples
• For example:
• Using the man command is a great way to explore and learn about various commands,
functions, and system features available in Linux, providing you with detailed
documentation to understand their usage and options thoroughly.
7
ls [OPTION]… DIRECTORY/IES
• List files and directories on current or given directory
• useful flags:
8
pwd
• find the path to current working directory
• for example:
9
mkdir [OPTION]… DIRECTORY/IES…
• Make directories much faster than with manual clicking
• If you want to create multiple directories at once, just separate their names with space
• Useful flags:
• For example:
– mkdir new_directory creates a directory called “new_directory”
– mkdir –p new/intermediate/dirs will create 3 new directories if none of them already exist
10
tee [OPTION]… FILE/S…
• tee command takes the standard input, displays the
output and also saves it to one or more files
• tee can be used to replace and to add content to
the file, if file doesn’t exist – it will be created
• useful flags:
– -a : it appends the output to the files rather than
overwriting them
• Useful flags:
– -v : cause cp to be verbose, showing files as they are copied.
– -r (or –R) : copy directory content recursively
• For example:
12
m v [ O P T I O N ] … S O U R C E … D E ST I N AT I O N
• Rename or move files and directories with their content from one destination to another
• Useful flags:
– -i : interactive mode, which prompts for confirmation before overwriting existing files
• Examples:
13
T H E E N D O F PA RT 1
T H A N K YO U
14