Basic Linux Commands
Basic Linux Commands
####################
BASIC LINUX COMMANDS
################################################################################
####################
=======
mkdir
=======
Is used to create directories.
[oracle@pc12c1
[oracle@pc12c1
[oracle@pc12c1
[oracle@pc12c1
Desktop]$
Desktop]$
Desktop]$
Desktop]$
mkdir
mkdir
mkdir
mkdir
/u01/dev
/u01/dev/d1
/u01/dev/d2
/u01/dev/d3
=======
cat
=======
Is used to read from a file as well as write onto a file.
Writing to a file
----------------[oracle@pc12c1 Desktop]$ cat >> /u01/dev/f1.txt
This is my first file.
^Z
[1]+ Stopped
cat >> /u01/dev/f1.txt
Reading from a file
------------------[oracle@pc12c1 Desktop]$ cat /u01/dev/f1.txt
This is my first file.
=======
ls
=======
Is used for listing files and directories
ls
-ls with no option list files and directories in bare format where we won
o view details like
file types, size, modified date and time, permission and links etc.
[oracle@pc12c1 Desktop]$ ls /u01/dev
d1 d2 d3 f1.txt
ls -l
----Here, ls -l shows file or directory, size, modified date and time,
file or folder name and owner of file and it s permission.
[oracle@pc12c1 Desktop]$ ls -l /u01/dev
t be able t
total 16
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
-rw-r--r--
2
2
2
1
oracle
oracle
oracle
oracle
d1
d2
d3
f1.txt
ls -a
-----lists all files along with the hidden files.
[oracle@pc12c1 Desktop]$ ls -a /u01/dev
. .. d1 d2 d3 f1.txt
ls -lh
-----Displays the size in human readable format
[oracle@pc12c1 Desktop]$ ls -lh /u01/dev
total 16K
drwxr-xr-x 2 oracle oinstall 4.0K Jan 13
drwxr-xr-x 2 oracle oinstall 4.0K Jan 13
drwxr-xr-x 2 oracle oinstall 4.0K Jan 13
-rw-r--r-- 1 oracle oinstall 23 Jan 13
22:05
22:05
22:05
22:06
d1
d2
d3
f1.txt
22:06
22:05
22:05
22:05
f1.txt
d3
d2
d1
ls -r
----Displays in reverse order
[oracle@pc12c1 Desktop]$ ls -r /u01/dev
f1.txt d3 d2 d1
[oracle@pc12c1 Desktop]$ ls -lr /u01/dev
total 16
-rw-r--r-- 1 oracle oinstall 23 Jan 13
drwxr-xr-x 2 oracle oinstall 4096 Jan 13
drwxr-xr-x 2 oracle oinstall 4096 Jan 13
drwxr-xr-x 2 oracle oinstall 4096 Jan 13
ls -R
----Display the contents recursively
[oracle@pc12c1 Desktop]$ ls -R /u01/dev
/u01/dev:
d1 d2 d3 f1.txt
/u01/dev/d1:
a.txt
/u01/dev/d2:
b.txt
/u01/dev/d3:
==============
cp
==============
Is used to copy files from one location to another.
[oracle@pc12c1 Desktop]$ cp /u01/dev/d2/b.txt /u01/dev/d3
[oracle@pc12c1 Desktop]$ ls /u01/dev/d3
b.txt
=============
mv
=============
Is used to move or rename file.
Renaming a file
[oracle@pc12c1 Desktop]$ mv /u01/dev/f1.txt /u01/dev/f2.txt
Moving a file
[oracle@pc12c1 Desktop]$ mv /u01/dev/f2.txt /u01/dev/d3
===========
alias
===========
Defines command macros
[oracle@pc12c1 Desktop]$ alias ld="ls -l | grep ^d"
[oracle@pc12c1 Desktop]$ ld
drwxr-xr-x 7 oracle oinstall
drwxrwxrwx 8 oracle oinstall
drwxr-xr-x 5 oracle oinstall
drwxr-xr-x 2 oracle oinstall
4096
4096
4096
4096
Jul
Nov
Jan
Jan
7
26
13
11
============
rm
============
Is used to remove directories.
[oracle@pc12c1 Desktop]$ ls /u01/dev/
d1 d2 d3 f1.txt f2.txt
[oracle@pc12c1 Desktop]$ rm -i /u01/dev/f*
rm: remove regular file `/u01/dev/f1.txt'? n
rm: remove regular file `/u01/dev/f2.txt'? y
`
[oracle@pc12c1 Desktop]$ ls /u01/dev/
d1 d2 d3 f1.txt
Recursively delete directories
[oracle@pc12c1 Desktop]$ rm -r /u01/dev
2014
02:48
22:07
21:18
database
firefox
Oracle On Linux
PT Books
=============
du
=============
Disk space usage by directories
[oracle@pc12c1 Oracle On Linux]$ du -h
12K
./MyPractical
6.6M
./E-Kit
5.5M
./Labs
12M
.
-h is used produce the results in human readable format
[root@localhost ~]# du -h /u01/app/oracle/oradata
1.1G
/u01/app/oracle/oradata/orcl
1.1G
/u01/app/oracle/oradata
============
zip
============
Is used to zip files
[oracle@pc12c1 MyPractical]$ zip myfiles f1.txt f2.txt f3.txt
adding: f1.txt (deflated 72%)
adding: f2.txt (deflated 72%)
adding: f3.txt (deflated 72%)
===========
touch
===========
Is used to create a new file and to change the timestamp of access and modificat
ion.
--Create a new file
[oracle@pc12c1 MyPractical]$ touch f4.txt
--Change the modification time
[oracle@pc12c1 MyPractical]$ touch -m f3.txt
--Change the access time
[oracle@pc12c1 MyPractical]$ touch -a f3.txt
--Change the access time to a specific date
[oracle@pc12c1 MyPractical]$ touch -d '1 May 2005 10:22' file4