In: Computer Science
what is the difference between ls and ps commands please explain properly with writing and executing commands and state the differences.
The name of subject is linux/unix
ls command lists directory contents of files and
directories.
There are various options available with ls command.
Example:
ls <Directory>
//will
show contents of that directory
ls -d
//will only show the directories
ls -l
//Will show all the files and directories with
appropriate permissions
ls -s
//Will show the size
Screenshot of the execution of the above commands is attached below.
ps command will lists all the current running processes.
It is used to find process identifier numbers.
The result after ps command contains four columns.
PID
//Process number
TTY
//Name of the console
TIME
//The amount of CPU in second and minutes
CMD
//Name of the command that launched the
process
ps -F command will show some extra information including user id.
Screenshot of the execution of the above commands is attached below.
The main difference between ls and ps command is :
ls will show the contents on that directory and ps will show the current running processes in the system.