Basic Linux Commands
Hello again, I’m constantly surprised by people who tell me they’d like to try Linux, but think it’s “too hard on commands”. I know that the linux commands may look scary at the beginning. But commands are the great way to understand Linux and learn so much about it. With Linux commands you can do a lot of things like rename or move files easier than a graphic interface, watch or stop system processes, start or stop system services.
Now, I’ll share the most basic Linux commands for beginners.
Basic Linux System Commands
1 2 3 4 5 6 |
whoami : show the current user date : show the system date uptime : show uptime clear : clear the terminal output cat : Display file’s contents to the standard output man : show manual for the command “man firefox” or “man cd” |
File Commands
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
cd : change to home directory cd <directory> : Change the directory to <directory>. Note: this must be a relative path, If you are in home and want to go to Desktop you only need to put; cd Desktop cd /<directory> : In linux the “/” represents the root directory is like the C:/ in windows, no matter in what directory you are, if you put ‘/’ all the path must be relative to this. cd /home/yourusername/Documents cd ~/<directory> : The “~” represents the home directory, you can put paths relative to the home directory like cd ~/Documents cd.. : Move to the parent directory of the current directory. pwd : Print the full filename of the current working directory ls : List the current directory content ls -l : List the current directory content with additional info like the owner, last edit, permissions. ls -a : List current directory content, even the hidden content. Note: If you want to create hidden folders or files the name needs to start with “.” , Also you can combinate arguments like; ls -la <- this command shows all the content of the current directory even the hidden content and extra info. cp <origin-file-path> <destination-path> : Copy a file to another location. Note: Like the cd command you can use a relative path to the current directory, to the home directory(~) or to the root directory(/) cp -r <origin-folder-path> <destination-path> : Copy a folder to another location. Note: the argument -r is required to copy, move or remove folders. mv <origin-file-path> <destination-path> : Move a file or folder(-r argument) to another location. Note: If you want to rename a file You can use this command, only need to put the original file name and the new file name mv helloworld.txt helloworld.c rm <file-name> : Delete a file or folder(-r argument). mkdir <folder-name> : Create a folder nano <file-name> : Nano is text editor in console, if the <file-name> doesn’t exist nano creates the file and if exist nano opens the file. chmod <777> <file-name> : chmod is a command that allows you change the permissions for a file or a folder(-r argument),the easiest way it is composed by three arguments the first value is for user permissions, the second for the group and the third for others, the permission for read is represented by a 4, for write is 2 and for execute is 1, the sum of the permissions is equal to 7 chmod 741 Documents |
Basic Process Commands
1 2 3 4 |
ps -a | grep <process-name> : Give info for some program that is in execution like the PID (Process ID). ps -a | grep firefox Note: Also you can use the “ps -a” command to see all your system process. kill -9 <PID> : Kill or stop the execution for a process or program. kill -9 255 free - < b | k | m > : Show some information about the RAM and swap space usage, the argument is for the size in which the info be displayed, b for bytes, k for kilobytes and m for megabytes. |
Conclusion
If you’ve never tried Linux, or tried it many years ago and gave up just because Linux commands, I’d encourage you to think again.
Thank you for visit me… 🙂