Useful Linux Commands - Part 3

The following are a list of commonly used Linux Administration Commands.

Linux File and Directory Commands

Linux Command Description
ls List files in current directory
ls -l List files in current directory using long listing method
ls -a List hidden files in current directory (Files prefixed with a "." dot)
ls -rtl List files in reverse time order using long listing method
ls -F List files in current directory, display directories with a trailing slash "/"
ls -i List files in current directory, display inode information
cd dir Change to Directory dir
cd .. Change to a directory one level higher than current directory
cd ~ Change to home Directory of current user
cd - Change to previous directory
pwd Display current Directory
rm file Delete specified file
rm -fr dir Delete Directory dir and its contents
rm -i Confirm Deletion with the "-i" option by replying "y" when prompted
cp file1 file2 Copy file1 to a file called file2
cp -r dir1 dir2 Copy Directory dir1 to directory dir2
mv file1 file2 Rename or move file1 file2
touch file Create or update a file
cat file1 Display content of file1
cat file1 file2 > file3 Concatenate contents of file1 and file2 and send to a new file called file3
tac Same as cat command, however file contents are reversed
strings Display printable characters from within a file
more file Display the contents of the specified file
head file Display the first 10 lines of a file
tail file Display the last 10 lines of a files
less file Display the contents of the specified file
> file Nulls file (makes file Zero bytes in size)
file file Display file type: ASCII text, executable, binary etc..
ln -s file link Create symbolic link link to file

Linux Permission Commands

Frequently used Linux permission commands

Linux Command Description
chgrp group file Change group on file>
chown user:group file Change ownership of file file> to user:group
chmod + or - Change permissions + adds permission - removes r=read, w=write, x=execute
chmod 777 file Change permissions to rwxrwxrwx on file
chmod +x file Change file to be executable by Owner,Groups and others.
chmod -x file Remove execute permissions from file
chmod -R 640 /dir Recursively change permissions of directory dir and any files/directories contained within

Linux Compression Commands

Frequently used Linux compression commands

Linux Command Description
tar cvf your.tar files Create a tar file called your.tar comprising of files
tar xvf your.tar Extract files from your.tar
tar tvf your.tar View contents of files in your.tar
tar czf your.tar.gz files Create a compressed tar file with Gunzip
tar xzf your.tar.gz Extract files from compressed archive
tar cjf your.tar.bz2 Create a compressed archive file with bzip2
tar xjf your.tar.bz2 Extract files from compressed archive
gzip file Compress file and rename to file.gz
gzip -d file.gz Decompress file.gz back to file