Basic Linux Commands
Command
ls
Usage
ls /directory_path
Description
List files
eg: ls /usr/lib
cp
cp file_path /destination_directory_path
Copy files
eg: cp student /home/cloudera/Desktop
mv file_path
/destination_directory_path
mv
eg: mv myfile.txt /newdirectory
Renames a file or moves
it from one directory to
another directory
mv current_filename new_filename
eg: mv computer.txt computer_hope.txt
rm file_path
rm
Delete files
eg: rm /home/cloudera/Desktop/file_name
ln file_path /destination_directory_path
ln
Link files
eg: ln student /home/cloudera/Desktop
cd /Directory_path
Change directory
cd
eg: cd /usr/lib/Hadoop-0.20
pwd
pwd
Print current directory
name
Command
Usage
Description
mkdir /new_directory_path
mkdir
eg: mkdir
/home/cloudera/Desktop/new_directory
Create directory
rmdir /directory_path
rmdir
eg: rmdir
/home/cloudera/Desktop/directory
Delete directory
cat /file_path
cat
View files
eg: cat /home/cloudera/file_name
nl /file_path
nl
Number lines
eg: nl studentRoll
vi /file_path
vi
Text Editor
eg: vi studentRoll
stat /file_path
stat
Display file
attributes(properties)
eg: stat studentRoll
wc /file_path
wc
Count bytes/words/lines
eg: wc studentRoll
Command
Usage
Description
chown user_name file_path
chown
eg: chown cloudera
/home/cloudera/Desktop/README.txt
Change file owner
chgrp group_name /file_path
chgrp
eg: chgrp admin
/home/cloudera/Desktop/README.txt
Change file group
ifconfig
ifconfig
Set/display network
information/ Ip address
sudo chattr +i/-i /file_path
chattr
eg: sudo chattr +i
/home/cloudera/Desktop/README.txt
Change advanced file
attributes