Start GUI
[raja@AGRAJA ~]$ startx
[raja@AGRAJA ~]$ startxfce4
Open File Manager in Terminal (Midnight Commander)
[raja@AGRAJA ~]$ mc
Mounting devices and file partitions
[root@AGRAJA~]#mount -t vfat /dev/sda5 /mnt/wind
Note: There should be a folder named wind under mnt
Here sda5 denotes D:drive in Windows (may differ).
The above applies for dual booting windows and linux on the same system
Unmounting :
[root@AGRAJA~]#umount /dev/sda5
Switching workspaces
CTRL+ALT+direction keys
Switching between open terminals
ALT+numberNote: number may be 1, 2, …
Open Terminal with default window position
[raja@AGRAJA ~]$ xterm -geometry WIDTHxHEIGHT+XOFF+YOFF
[raja@AGRAJA ~]$ xterm -geometry 100x100+100+100 &
List Directories Only
[raja@AGRAJA ~] ls -d */
Show Directory Size
[raja@AGRAJA ~] du
Show Size of Virtual Memory
[raja@AGRAJA ~] du /tmp
Show Free Space
[raja@AGRAJA ~] df
Change Directory to 1) Home
[raja@AGRAJA somedir]$ cd
[or]
[raja@AGRAJA someidr]$ cd ~
2) Previous Directory or Back
[raja@AGRAJA somedir]$ cd -
Quickly enter previous commands
Method 1: Use up or down arrow keys.If it does’nt work try after typing !
Method 2:
Step i: CTRL+r
Step ii: Start typing the command. If it were entered previously, it will be predicted/autocompleted/suggested. Then press return key
Clear screen
Method 1: Type “clear” at the terminal
Method 2: CTRL+l
Alias
[raja@AGRAJA ~] alias new_command_name shell_command [raja@AGRAJA ~] alias cls clear [raja@AGRAJA ~] alias dir ls
Link
[raja@AGRAJA ~] ln -s /home/raja/scripts/script_name script_name
Stop executing a command
CTRL+c
Change file permissions
[raja@AGRAJA ~] chmod 755 file.extension
[raja@AGRAJA ~] chmod -R 755 directory_and_contents
Copy Files
To copy all files and subdirectories from current directory to destination directory
[raja@AGRAJA source_dir]$ cp -r * /home/raja/dest_dir
To copy an existing_directory to new_directory
[raja@AGRAJA parent_dir]$ cp -r existing_directory new_directory
To copy an existing_directory to present working directory
[raja@AGRAJA work_dir]$ cp -r /home/source_dir .
Archive Handling
Create a tar file
[raja@AGRAJA ~] tar -cvf archive.tar file1.doc file2.c dir1 dir2
Create compressed archive
[raja@AGRAJA ~] tar -cvjf file.tar.bz2 file_or_dir
[raja@AGRAJA ~] tar -cvzf file.tar.gz file_or_dir
[raja@AGRAJA ~] tar -cvZf file.tar.Z file_or_dir
Untar an archive
[raja@AGRAJA ~] tar -xvf archive.tar
Search for Files
[raja@AGRAJA ~]$ find -name '*part_of_file_name*'
[raja@AGRAJA ~]$ find -name full_file_name.extension
Search for text in files
[raja@AGRAJA ~]$ grep -r search_text .
Find out where an application is installed
[raja@AGRAJA ~]$ which bash
[raja@AGRAJA ~]$ whereis vim
Executing Multiple Commands
1) Running sequentially
[raja@AGRAJA installsoftware]$ ./configure && make && make install
[raja@AGRAJA installsoftware]$ ./configure ; make ; make install
2) Passing output
[raja@AGRAJA ~]$ ls | less
List all users and their processes
[raja@AGRAJA ~]$ w
Run programs even after logging off
[raja@AGRAJA working_dir]$ nice nohup gcc large_program.c
[raja@AGRAJA working_dir]$ nice nohup tar -cvjf large_archive.bz2
List all current processes
[raja@AGRAJA working_dir]$ ps
[raja@AGRAJA working_dir]$ ps au
[raja@AGRAJA working_dir]$ pstree
[raja@AGRAJA working_dir]$ pstree -au
[raja@AGRAJA working_dir]$ top
Stop a running process
[raja@AGRAJA~]#kill PID
[raja@AGRAJA~]#kill -9 PID
Note: PID is a number obtained form previous command
use -9 to ensure "execution"
Change Run Level
Display current run level
[raja @AGRAJA ~] who –r
Change Run Level as rootReboot the system
[raja@AGRAJA ~] init 6
Halt the system
[raja@AGRAJA ~] init 0
List all installed software
[raja@AGRAJA deb_based_distro]$ dpkg –get-selections
[raja@AGRAJA rpm_based_distro]$ rpm -qa
Environment Variables
[raja@AGRAJA ~]$ env
Shell Variables
[raja@AGRAJA ~]$ set working_dir = /home/agraja/work
[raja@AGRAJA ~]$ cd $working_dir
[raja@AGRAJA work]$ unset working_dir