Basic Linux Commands



cd 


cd ~               go to home dir
cd ~username       go to user home dir
cd -               go to last dir
cd ./              same dir
cd ~/Music         go to home and then music
cd ..              back one dir
cd ../..           back two dir
cd /               go to root dir

sudo

sudo !!         run the previous command
su              switch user
su virus        login virus user
sudo su         become root user
exit            exit and go back to current user

touch

touch file.txt             create one empty file
touch file.txt file2.txt   create multiple empty files

remove

rm test.txt          delete test.txt
rm ./*.txt           delete all txt file in current dir
rm ./*               remove everything in current dir
rm mydir/*           remove everything in mydir
rm -rf mydir         remove it recursively and forcefully

copy

cp mydir home               copy mydir to home
cp mydir /virus/Desk        copy on particular location
cp mydir /home/ndir         copy mydir to home with new name

cp my/test.txt your/test2.txt     copy from mydir to yourdir and rename test2

move

mv mydir/test.txt yourdir     move test.txt form mydir to yourdir

-f --force                Do not prompt before overwriting
-i --interactive          Prompt before overwriting

mkdir

mkdir dirname                   make single dir
mkdir /tmp/test-dir             make dir in dir
mkdir docs pub                  make multiple
mkdir -p /tmp/amrood/test       creates all the necessary directories.

rm

rmdir dirname                      remove directory
rmdir dirname1 dirname2 dirname3   remove multiple dir

mv 

mv mydir/test.txt yourdir      move test.txt from mydir to yourdir

ctrl + r – search command history

ctrl + a – go to the start of line

ctrl + e – go the the end of line

ctrl + z – sleep program

cat     show content of file
man     show manual
locate  finds files
clear   clear terminal

No comments:

Post a Comment

Popular Posts