Linux Commands
Linux Commands
Introduction
Linux commands are just simple programs like a
program in windows. Typing command is like
clicking an icon in windows.
$ man <command>
$ man clear
ls (list items)
$ pwd
it will print current directory
~ Your Home Directory
By typing cd ~ in terminal it will take you to the
home directory of current user
$ cd ~
cp (copy)
copies a file or entire directory to another path If
you want to copy files from another directory to
current directory use a . for destination
$ cp <source_file> <destination_file>
Tip: Always read the error carefully and please
don't freak out :)
mv (move file)
move command renames or move a file
$ mv file1.txt file2.txt
rm (remove)
rm removes a file or entire directory with -r flag
$ rm <file>
$ rm <directory> -r
clear
clears your screen
$ clear
cat
displays the content of files on screen.
$ cat file.txt
less
Iess is similar to cat but it displays content one
page at a time
$ less file.txt
head
head is a short version of less command. It
prints only first 10 lines.
$ wc -l file.txt
Writing input to output
type the cat command without file name. It will
start taking your text into output memory. Once
you press Ctrl + d the output will be printed on
screen.
$ cat
$ alpha
$ Ctrl + d
use cat to write a file
$ cat > file.txt
This will take your input and write to a file by
name file.txt from your input until Ctrl+d is
pressed.
Pipes
Piping means passing result of one command to
another command.