Linux Commands

Linux Commands

Part - 1

Linux was created by Linus Torvalds from scratch. It's free and open-source.That means you can simply change anything on Linux.

Get started with Linux using following ways:

  1. WSL.(Windows Subsystem Linux)
  2. VMWare. (Virtual Box)
  3. Booting USB (Dual boot).


Commands

  • echo
echo Hello, World!

echo command prints the text on the screen that is passed as an argument.

  • pwd
pwd

pwd gives the absolute path, which means the path that starts form root. It stands for present working directory or print working directory


  • ls
ls

ls stands for listing directory, shows the files and directories present in the current directory.

ls [directory]

Mention directory name after ls command to list all the files in that directory.

ls -a

-a flag is used with ls command to enlist the whole files (includes hidden files) in the current directory.

ls.png

ls -l

-l flag is used with ls command to have a detailed view of the every folder/directory in the current directory.

ls-l.png

ls -la

-la flag is used with ls command to have a detailed view of every file in all directories of current directory.

ls-la.png


  • cd
cd  [directory_name]

cd stands for change directory. Used to change current directory to other directory.

cd .

cd . Change to current directory.

cd ..

cd .. Change working directory to parent directory.

cd -

cd - Change current working directory to previous directory.

cd ~

cd ~ Change current working directory to home directory.

cd /

cd / Change current working directory to root directory.

cd.png

  • clear

clear command clears the terminal screen.


  • mkdir
mkdir [directory_name]

mkdir will create a directory with given name.

  • rmdir
rmdir [directory_name]

This command will remove a directory with given name. But only be used to delete empty directory.

mkdir-rmdir.png

  • touch
touch [filename.extension]

The touch command is used to create a file.

touch.png

  • cat
cat [filename]

cat command display the content of the file.

cat > [filename]

> is used with cat command to create a file and insert data into that. Press Ctrl+D to exit.

cat.png

  • rm
rm [file_name]

To delete a file rm command is used.

rm -r [dir_name]

-r is used to delete the files in a directory recursively and finally delete the directroy.

rm -rv [dir_name]

-v is used to display the verbose of which files are being deleted.

rm-all.png

rm -r [directory_name]

To delete a non-empty directory use -r as flag along with rm command.

rm.png


  • man & help
man sudo
sudo --help

To know more about a command use man. It shows the manual pages for a command.

man.png

help.png

  • history

To see history of the commands.


  • cp
cp [filename] [new_filename]
cp [file/directory] [target_directory/target_path]

cp command is used to copy a file/directory from one location to another, or just simply making copy of same file with another name.

  • mv
mv [file/directroy] [target_path]

mv command is use to move a file/directory form one location to another.

cp&mv.png


  • top
top

Lists the actively running processes.

top.png

  • open
open [file_path]

Opens the file/directroy in the file manager.

Thankyou.

Did you find this article valuable?

Support Phanee by becoming a sponsor. Any amount is appreciated!