DEV Community

murugan
murugan

Posted on

Basic Linux commands for developers

Basic Linux Commands for developers

FILE AND DIRECTORY COMMANDS

S.No Description Commands
1 List all files in a long listing (detailed) format ls -al
2 Display the present working directory pwd
3 Create a directory mkdir
4 Remove (delete) file rm file
5 Remove the directory and its contents recursively rm -r directory
6 Force removal of file without prompting for confirmation rm -f file
7 Copy file1 to file2 cp file1 file2
8 Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with the contents of source_directory cp -r source_directory destination
9 Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2 mv file1 file2
10 View the contents of file cat file
11 Browse through a text file less file
12 Display the first 10 lines of file head file
12 Display the last 10 lines of file tail file

ARCHIVES (TAR FILES)

S.No Description Commands
1 Create tar named archive.tar containing directory tar cf archive.tar directory
2 Extract the contents from archive.tar tar xf archive.tar
3 Create a gzip compressed tar file name archive.tar.gz. tar czf archive.tar.gz directory
4 Extract a gzip compressed tar file. tar xjf archive.tar.bz2
5 Create a tar file with bzip2 compression tar cjf archive.tar.bz2 directory
6 Extract a bzip2 compressed tar file tar xjf archive.tar.bz2

FILE PERMISSIONS

S.No Description Commands
1 chmod 777 filename rwx rwx rwx
2 chmod 775 filename rwx rwx r-x
3 chmod 755 filename rwx r-x r-x
4 chmod 664 filename rw- rw- r--
5 chmod 644 filename rw- r-- r--

NETWORKING

S.No Description Commands
1 Display DNS information for domain dig domain
2 Display DNS IP address for domain host domain
4 Display all local IP addresses of the host. hostname -I
5 Display listening tcp and udp ports and corresponding programs netstat -nutlp

INSTALLING PACKAGES

S.No Description Commands
1 Search for a package by keyword yum search keyword
2 Install package yum install package
3 Display description and summary information about package yum info package
4 Install package from local file named package.rpm rpm -i package.rpm
5 Remove/uninstall package yum remove package

SEARCH

S.No Description Commands
1 Search for pattern in file grep pattern file
2 Search recursively for pattern in directory grep -r pattern directory
3 Find files and directories by name locate name
4 Find files in /home/john that start with "prefix". find /home/john -name 'prefix*'

VIM Exiting

S.No Description Commands
1 write (save) the file, but don’t exit :w
2 write out the current file using sudo :w !sudo tee %
3 write (save) and quit :wq or :x or ZZ
4 quit (fails if there are unsaved changes) :q – quit
5 quit and throw away unsaved changes :q! or ZQ
6 search for pattern /pattern –

Top comments (0)