You are on page 1of 6

Linux Basic Commands

mkdir : to create directory

mkdir <dir name>

rmdir : to remove directory rmdit<dir name>


Cd : change directory
cd /tmp/
cat : to read only a file
cat test
cp : to copy a file
cp test /usr/local/apache
cp -R modules /usr/local/apache
if you are copying a file you can copy directly with out -R,
/usr/local/apache is destination path. if you are copying folder or directory
you should mention -R(reccursivly)
mv : to move a file
mv <filename> <filename2>
for rename also we'll use this
rm : to remove a file
rm <filename>
rm -R <filename> is directory
ls : to list files in directory
ls -ltr : to list file with size and timestamps
more : more is also used to read a file
more test
locate : to locate an file in directory
locate <file name>
pwd : present working directory
chmod : use to change the permission of file or directory
chmod 777 <filename>
chmod 777 -R <file name>

chown : used to change the user and group name (this should run from root
user only)
chown <used id><groupid> <filename>
chown <used id><groupid> -R <dir name>
gzip : to zip a file

gzip <file name>

unzip : to unzip a file

unzip <file name> or

gunzip <file name>

tar : used while working with .tar file


to make a tar file tar -cvf <filename>
to untar a file
tar -xvf <file name>
ps -ef : to find all the running process in JVM
ps -ef | grep java : to find only java processes
ps -ef|grep jboss to find jboss process
ps -ef|grep apache
to find apache processes
| means first command output will be input for second output
diff : to find the differences between two files
diff <file name> <file name2>
date : to find the server date and time
cal : to list the calender
cal it'll display the calender
cal 02 2015 to list feb 2015 month
df -k : to check the memory status
du -sh : to find the disk usage
free : to find the free space in disk(in bytes)
free -m : to fine the free space in MB's
free -g : to find the free space in GB's
top : to list the processes with their cpu usage
kill : to kill the processes
kill -9 <process id>
ping : used to check the network connection
ping <ipaddress>

telnet : used to find the network connection with port listen


telnet <ip address> <port>
passwd : to change the password
su : to switch user

su <linux account>

history : to list the history done in past


man : if you don't know about any command
man <command>
nslookup : to find the ipaddresses of the domain name
nslookup www.google.com
scp : used to copy the files from one remote server to another
scp <filename> <destination server ipaddress or hostname>:/<path
to be copied>
tail : used to read an file
tail -f <file name> to read file from latest updates
tail -f100 <filename> to read the latest updated 100 lines of file
uname : prints the system information
who : prints all user name presently logged on
clear : to clear the screen
ipconfig : it'll list out the configuration
netstat : to find the listining port in jvm
ln : to create the soft/sybolic link nothing but short cut for folder in windows
ln -s <path of original diretory> <short name>
touch : to create an empty file
touch <file name>
vi : to open an file with editable mode
vi <file name> we can create the new file also like this
after enter into vi esc+q to quit with out saving
esc+wq to quit with saving

to start servers :
jboss : do to server path and go to bin : ./run.sh (./shutdown.sh)
tomcat : go to server bin : ./startup.sh (./shutdown.sh)
apache : go to server bin : ./apachectl start (./apachectl stop)
(for windows file extention with.bat and for linux extention is .sh)

file permissions : chmod


The chmod command allows you to alter access rights to files and
directories. All files and directories have security permissions that grant the
user particular groups or all other users access. you can enter the "ls -ltr"
from an directory
You should see some files with the following in front of them (an example
follows):
total 4
drwxrwsr-x 7 reallyli reallyli 1024 Apr 6 14:30 .
drwxr-s--x 22 reallyli reallyli 1024 Mar 30 18:20 ..
d-wx-wx-wx 3 reallyli reallyli 1024 Apr 6 14:30 content
drwxr-xr-x 2 reallyli reallyli 1024 Mar 25 20:43 files
What do the letters mean in front of the files/directories mean?
r indicates that it is readable (someone can view the files contents)
w indicates that it is writable (someone can edit the files contents)
x indicates that it is executable (someone can run the file, if executable)
- indicates that no permission to manipulate has been assigned
When listing your files, the first character lets you know whether youre
looking at a file or a directory. Its not part of the security settings. The next
three characters indicate Your access restrictions. The next three indicate
your group's permissions, and finally other users' permissions.
Use chmod followed by the permission you are changing. In very simple form
this would be:
chmod 755 filename
The example above will grant you full rights, group rights to execute and
read, and all others access to execute the file.
#Permission
7
full
6

read and write

read and
execute
4 read only
write and
3
execute
2 write only
1 execute only
0 none
5

Still confused? Use the table above to define the settings for the three
"users." In the command, the first number refers to your permissions, the
second refers to group, and the third refers to general users.
Typing the command: chmod 751 filename
gives you full access, the group read and execute, and all others execute
only permission.

You might also like