Linux Commands

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

chmod

chmod is the command used to make a file executable and to change the permissions granted to it in Linux. Imagine you have a python code named numbers.py in your computer, you'll need to run "python numbers.py" every time you need to run it. Instead of that, when you make it executable, you'll just need to run "numbers.py" in the terminal to run the file. To make a file executable, you can use the command "chmod +x numbers.py" in this case. You can use "chmod 755 numbers.py" to give it root permissions or "sudo chmod +x numbers.py" for root executable. Here is some more information about the chmod command.

clear

clear the terminal if it gets filled up with too many commands!

echo

command that helps us move some data, usually text into a file. For example, if you want to create a new text file or add into an already made text file, then you just need to type in "echo hello, my name is alok >> new.txt". You do not need to separate the spaces by using the backward slash here because we put in two triangular brackets when we finish what we need to write.

du

command to know the disk usage of a file in your System. If you want to know the disk usage for a particular folder or file in Linux, then you can type in the command df and the name of the folder or file. For example, if you want to know the disk space used by the folder Documents in Linux, you can use the command "du Documents". You can also use the command "ls -lah" to view the file sizes of all the files in a folder.

cd

"choose directory" case sensitive

cp

"copy" used to copy files through the command line. It takes two arguments, the first one is location of the file to be copied, the second iswhere to copy.

ls

"list" Used to know what files are in the directory

mkdir/rmdir

"make directory" used to create a folder or directory. "remove directory" can only be used to delete an empty directory. Use rm to delete a directory containing files.

mv

"move" used to move files through the command line. We can also use the mv command to rename a file. For example, if we want to rename the file "text" to "new", we can use "mv text new". It takes the two arguments just like the cp command.

pwd

"print working directory" It gives us the Absolute Path, which means the path that starts from the root. The root is the base of the Linux filesystem.

rm

"remove" used to delete files/directories. rm cannot simply delete a directory. "rm -r" is used to delete a directory. In this case, it deletes both the folder and the files in it.

Basic

Commands

Intermediate

Commands

man/-help

To know more about a command and on how to use it, the man command is used. It shows the manual pages of the command.

apt-get

apt is a command used to work with packages in the Linux command line. apt-get is a command used to install packages. This requires root privileges, so we use the sudo command with it. For example, if we want to install the text editor jed (as I mentioned earlier), we can type in the command "sudo apt-get install jed". Similarly, any packages can be installed like this. It is good to update your repository each time you try to install a new package. You can do that by typing "sudo apt-get update". You can upgrade the system by typing "sudo apt-get upgrade". We can also upgrade the distro by typing "sudo apt-get dist-upgrade". The command "apt-cache search" is used to search for a package. If you want to search for one, you can type in "apt-cache search jed"(This doesn't require root).

tar

command used to work with tarballs (or files compressed in a tarball archive) in the Linux Command Line. It has a long list of uses. It can be used to compress and uncompress different types of tar archives like .tar, .tar.gz, .tar.bz2.etc. It works on the basis of the arguments given to it. For example, tar -cvf for creating a .tar archive, -xvf to untar a tar archive, -tvf to list the contents of the archive.etc. https://www.tecmint.com/18-tar-command-examples-in-linux/

exit

exit the terminal

nano, vi, jed

nano and vi are already installed text editors in the Linux command line. nano is a good text editor which denotes keywords with color and can recognize most of the languages. Vi is simpler than nano. You can create a new file or modify one using this editor. For example, if you need to make a new file named "check.txt", you can create it by using the command "nano check.txt". You can save your files after editing by using the sequence, Ctrl+X, then Y (or N for no). In my experience, using nano for HTML editing doesn't seem so good, because of its color, so I recommend jed text editor. We will come to installing packages soon.

sudo halt

power off the computer

sudo reboot

reboot the computer

ping

used to check your connection to a server. Wikipedia says that "Ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol (IP) network". Simply, when you type in, for example, "ping google.com", it checks if it can connect to the server and come back. It measures this round-trip time and gives you the details about it

touch

used to create a file. It can be anything, from an empty txt file to an empty zip file. For example - "touch new.txt"

cat

used to display the contents of a file, usually used to easily view programs.

TAB

used to fill up in Terminal. For example, You just need to type "cd Doc" and then TAB and the terminal fills the rest up and makes it "cd Documents".

Ctrl+Z

used to force stop it.

hostname

used to know your name in your host or your network. Basically, it displays your hostname and IP address. Typing just "hostname" gives the output, your hostname. Typing in "hostname -I" gives you your IP address in your network.

locate

used to locate a file in a Linux System, just like the search command in Windows. This command is useful when you don't know where a file is saved or the actual name of the file. Using the -i argument with the command, helps to ignore the case (it doesn't matter if it is Capital or Small). So, if you want a file that has the word "hello", it gives the list of all the files in your Linux System containing the word "hello" when you type in "locate -i hello". If you remember two words, you can separate it using asterisk (*). For example, to locate a file containing the words "hello" and "this", you can use the command "locate -i *hello*this "

df

used to see the available disk space in each of the partitions in your system. You can just type in df in the command line and you can see each mounted partition and their used/available space in % and in KBs. If you want it shown in megabytes, you can use the command "df -m"

uname

used to show the Information about the system your Linux distro is running. Using the command "uname -a" prints most of the information about the system. This prints the Kernel release date, version, processor type. etc.

Ctrl+C

used to stop any command in terminal safely. If it doesn't stop with that

sudo

widely used command in the Linux command line. sudo stands for "SuperUser Do". So, if we want any command to be done with administrative or root privileges, then you can use the sudo command. For Example, if you want to edit a file like viz. alsa-base.conf which needs root permissions, you can use the command - sudo nano alsa-base.conf . You can enter the root command line using the command "sudo bash", then type in your user password. You can also use the command "su" to do this, but you need to set a root password before that. For that, you can use the command "sudo passwd"(it wasn't misspelled, it is passwd). Then type in the new root password.

zip, unzip

zip is a command used to compress files into a zip archive, unzip is used to extract files from a zip archive.


Set pelajaran terkait

Leadership in Health professions test 1

View Set

31Qw/exp-NCLEX Questions for Leadership and Management

View Set

IFSTA 6th Edition Chapter 15: Fire Hose

View Set

Simple Interest and Compound Interest

View Set

Motor Learning and Performance Chapter 8

View Set

MUS 108: Exam #3, Ch. 21-27 Except 24

View Set

IGGY Chapter 26: Care of Patients with Burns

View Set