Here we have narrowed down the most required 38 commands one require at command line.
1. Commands For Directories
The below command display path of current working directory –
$ pwd
Command to Change directory to <directory>
$ cd <directory>
Command to Navigate to parent directory
$ cd ..
Command to List directory contents
$ ls
Command to List detailed directory contents, including
hidden files
$ ls -la
Command to create a new directory named <directory>
$ mkdir <directory>
2. Commands For Output
Output the contents of <file>
$ cat <file>
Output the contents of using <file> the less command (which supports pagination etc.)
$ less <file>
Output the first 10 lines of <file>
$ head <file>
Direct the output of <cmd> into <file>
$ <cmd> > <file>
Append the output of <cmd> to <file>
$ <cmd> >> <file>
Direct the output of <cmd1> to <cmd2>
$ <cmd1> | <cmd2>
Clear the command line window
$ clear
3. Commands for files
Delete <file>
$ rm <file>
Delete <directory>
$ rm -r <directory>
Force-delete <file> (add -r to force delete a directory)
$ rm -f <file>
Rename to <file-old> to <file-new>
$ mv <file-old> <file-new>
Move <file> to <directory> (possibly overwriting an existing file)
$ mv <file> <directory>
Copy <file> to <directory> (possibly overwriting an existing file)
$ cp <file> <directory>
Copy <directory1> and its contents to <directory2> (possibly overwriting files in an existing directory)
$ cp -r <directory1> <directory2>
Update file access & modification time (and create <file> if it doesn’t exist)
$ touch <file>
4. Commands for Permissions
Change permissions of <file> to 755
$ chmod 755 <file>
Change permissions of <directory> (and its contents) to 600
$ chmod -R 600 <directory>
Change ownership of <file> to <user> and <group> (add -R to include a directory’s contents)
$ chown <user>:<group> <file>
5. Commands for Search
Find all files named <file>. inside <dir> (use wildcards [*] to search for parts of filenames, e.g. “file.*”)
$ find <dir> -name "<file>"
Output all occurrences of <text> inside <file> (add -i for case-insensitivity)
$ grep "<text>" <file>
Search for all files containing <text> inside <dir>
$ grep -rl "<text>" <dir>
6. Commands for Network
Ping <host> and display status
$ ping <host>
Output whois information for <domain>
$ whois <domain>
Download <file> (via HTTP[S] or FTP)
$ curl -O <url/to/file>
Establish an SSH connection to <host> with user <username>
$ ssh <username>@<host>
Copy <file> to a remote <host>
$ scp <file> <user>@<host>:/remote/path
Check ip address of your system – windows
ipcofig (for windows)
ifconfig (for linux/macos)
7. Commands for Processes
Output currently running processes
$ ps ax
Display live information about currently running processes
$top
Quit process with ID <pid>
$ kill <pid>