Friday, September 16, 2011

Some useful commands in linux





ls -F


The -F option is to display a slash after each working directory and an asterix after each executable file


 to create a directory under a directory in one command


mkdir -p


for example


 mkdir -p sourav/sourav2/sourav3 


cd when using without arguement takes you to the home of current working directory


for example


pwd


/home/sourav


mkdir sourav3


cd sourav3


pwd


/home/sourav/sourav3


cd


pwd


/home/sourav


copy a file using relative pathname


pwd 


/home/sourav


mkdir -p sourav3/sourav4


cd sourav3


cat > sourav1.txt


Hello how are you


ctrl+z


cp sourav1.txt ..


ls ..


sourav1.txt will be shown in the home direc


cd ~


cat > sourav2.txt


Hello how are you


ctrl+z


cp sourav2.txt sourav3/sourav4


ls sourav3/sourav4


sourav2.txt will be shown
cp sourav2.txt


to add a new user


$ sudo useradd username -m -s /bin/bash 
$ sudo passwd username 


to login as a different user in terminal


sudo -i -u





No comments:

Post a Comment