This post lists the most commonly used commands in linux (or alike, like MacOS) system.
File System
$ whoami
prints the login name of the current user.
$ pwd
prints the current working directory (Print Working Directory)
$ ls
lists files and directories. Often used with options
-
ls -l
: -l option signifies the long list forma -
ls -a
: -a option means list hidden files -
ls -F
: -F option makes files of different types appear differently. Display a slash ('/') immediately after each pathname that is a directory, an asterisk ('*') after each that is executable, an at sign ('@') after each symbolic link etc.
$ cd
change directory. Note often used:
-
cd ..
go to parent directory -
cd -
go to previous directory -
cd ~
go to home directory
$ mkdir
creates a directory
$ rmdir
removes a (empty) directory
$ cp src dest
copies files/folders from one location to another
$ mv src dest
moves files/folders from one location to another
$ rm
removes files/folders. Often used:
-
rm -r folder_name
removes a folder and its content -
rm -rf folder_name
removes without prompts
Processes
$ ps
see the processes associated with the current shell. Often used with:
-
ps -ef
get a full listing of all processes in the system -
ps -ef | grep process_name
get process_name process
top
display the processes using the most CPU time. Often used with:
-
top -n 10
lists the top 10 processes that use the most CPU time
quit with q
kill
terminates a process kill PID
. Use kill -9 PID
to force kill.
Misc
$ vim
text editors for writing files.
Recommended: install plugins ultimate vim to make vim more powerful and colorful.
$ cat
$ more
$ less
view files
$ grep
search text files
$ gcc
$ gdb
compilers and debuggers
More
One can use man
to get a detailed explanation of commands
man cp
Top comments (0)