Pages

Ads 468x60px

Monday, July 23, 2012

Linux: Basic Commands

This will help you to understand the basic commands for Linux


1.     Show the present working directory
Ans. pwd shows the current working directory and stands for "print working directory".
        usman@ubuntu:~$ pwd

2.     Show the current user's session information in long format
Ans. usman@ubuntu:~$ finger -l

3.     Show the current user's group membership
Ans. usman@ubuntu:~$ groups usman              // 'usman' is the current user

4.     Show the current user's PATH
Ans. usman@ubuntu:~$ echo $path

5.     Make a directory in the current user's home directory called lab2
Ans. usman@ubuntu:~$ mkdir lab2       // your current directory should be user's home directory

6.     Make two files in the lab2 directory: test and .test
Ans. usman@ubuntu:~$ touch lab2/test
        usman@ubuntu:~$ touch lab2/.test

7.     Make a directory in the lab2 directory named sub1
Ans. usman@ubuntu:~$ mkdir lab2/sub1

8.     Use head to show the first line in 'test'
Ans. usman@ubuntu:~$ head -1 lab2/test

9.     Use tail to show the last line in 'test'
Ans. usman@ubuntu:~$ tail -1 lab2/test

10.   Use cat to show the contents of test
Ans. usman@ubuntu:~$ cat -A lab2/test

11.   Change to the current user's home directory
Ans. usman@ubuntu:~$ cd

12.   Use ls to recursively list the lab2 directory
Ans. usman@ubuntu:~$ ls -R lab2

13.   Use rmdir to delete the sub1 directory
Ans. usman@ubuntu:~$ rmdir lab2/sub1

14.   Use rm to delete the lab2 directory recursively
Ans. usman@ubuntu:~$ rm -R lab2

No comments:

Post a Comment