Linux Commands

¡Supera tus tareas y exámenes ahora con Quizwiz!

fg

A process in the background is immune from terminal keyboard input, so to return a process to the foreground, use the fg command. The fg command followed by a % and the job number (called a jobspec) is how to do it. If you only have one background job, the job number is optional.

chmod

Change the file permissions for a file or directory. chmod is used to change the read, write, and execute permissions of files and directories.

chgrp

Change the group of a file or directory

chown

Change the owner of a file or directory. In Linux, all files are owned by a specific user. The chown command enables you to change or transfer the ownership of a file to the specified username. For instance, chown linuxuser2 file.ext will make linuxuser2 as the owner of the file.ext.

which

Find where a command in PATH is located

lsusb

Get a list of USB devices plugged into your system

gpg

GnuPrivacy Guard (GPG) allows you to securely encrypt files so that only the intended recipient can decrypt them

adduser

High level utility for adding new user accounts

hostname

If you want to know the name of your host/network simply type hostname. Adding a -i to the end will display the IP address of your network.

iwlist

Iwlist is used to display some additional information from a wireless network interface that is not displayed by iwconfig

ssh

Login to a remote device with SSH. ssh acronym for Secure Shell is protocol which is used to securely connect to host system. ssh username@host<IP/Domain Name> is the command to connect to host computer as a user.

usermod

Modify a user account

sha1sum

Print or Check SHA Checksums

reboot

Reboot the system

top

See a list of processes and their resource usage. As a terminal equivalent to Task Manager in Windows, the top command will display a list of running processes and how much CPU each process uses. It's very useful to monitor system resource usage, especially knowing which process needs to be terminated because it consumes too many resources.

whoami

See which user you are currently logged in as

sudo

Short for "SuperUser Do", this command enables you to perform tasks that require administrative or root permissions.

find

Similar to the locate command, using find also searches for files and directories. The difference is, you use the find command to locate files within a given directory. (**look at main pdf for examples**)

userdel

Since Linux is a multi-user system, this means more than one person can interact with the same system at the same time. useradd is used to create a new user, while passwd is adding a password to that user's account. To add a new person named John type, useradd John and then to add his password type, passwd 123456789. To remove a user is very similar to adding a new user. To delete the users account type, userdel UserName

shred

So, in order to delete a file completely from hard disk "shred" is used in Linux. This command overwrites the contents of a file multiple times, using patterns chosen to maximize the destruction of the residual data, making it harder for even very expensive hardware probing to recover it.

crontab

The crontab (abbreviation for "cron table") is list of commands to execute the scheduled tasks at specific time. It allows the user to add, remove or modify the scheduled tasks. The crontab command syntax has six fields separated by space wher the first five represent the time to run the task and the last one is for the command. • Minute (holds a value between 0 and 59) • Hour (holds value between 0 and 23) • Day of Month (holds value between 1 and 31) • Month of the year (holds a value between 1 and 12 or Jan to Dec, the first three letters of the month's name shall be used) • Day of the week (holds a value between 0 and 6 or Sun to Sat, here also first three letters of the day shall be used) • Command

dmesg

The dmesg command allows you to review the messages that are stored in the ring buffer. By default, you need to use sudo to use dmesg.

head

The head command is used to view the first lines of any text file. By default, it will show the first ten lines, but you can change this number to your liking. For example, if you only want to show the first five lines, type head -n 5 filename.ext.

iw

The iw command is used to view and manage wireless devices and their configurations.

locale

The locale command displays information about the current locale, or all locales, on standard output.

md5sum

The md5sum is designed to verify data integrity using MD5 (Message Digest Algorithm 5). Importance: Suppose, anyone wants to install an operating system , so to verify if it's correct CD, it's always a good idea to verify .iso file using MD5 checksum, so that you don't end up installing wrong software (some sort of virus which can corrupt your filesystem).

shutdown

The shutdown command safely exits the system. Warns all logged in users and disables access (see login (1)). The process can be started immediately or after a specified time, in which all applications are notified first with the SIGTERM signal.

ss

The ss (socket statistics) tool is a CLI command used to show network statistics.

tar

The tar command is the most used command to archive multiple files into a tarball, a common Linux file format that is similar to zip format, with compression being optional. This command is quite complex with a long list of functions such as adding new files into an existing archive, listing the content of an archive, extracting the content from an archive, and many more.

touch

The touch command allows you to create a blank new file through the Linux command line. As an example, enter touch /home/username/Documents/Web.html to create an HTML file entitled Web under the Documents directory.

uname

The uname command, short for Unix Name, will print detailed information about your Linux system like the machine name, operating system, kernel, and so on.

netstat

This command is for those who need to monitor incoming and outgoing network connections continuously. netstat command displays the network status, routing tables and interface statistics.

echo

This command is used to move some data into a file. For example, if you want to add the text, "Hello, my name is John" into a file called name.txt, you would type echo Hello, my name is John >> name.txt

tail

This one has a similar function to the head command, but instead of showing the first lines, the tail command will display the last ten lines of a text file. For example, tail-n filename.ext

who

This one is for system administrators who handle and manage various users on Linux system. who command when executed in Terminal show the complete list of those users who are currently logged into Linux system.

traceroute

Trace the network path taken to a device

clear

Use the clear command to clean out the terminal if it is getting cluttered with too many past commands.

ping

Use the ping command to check your connectivity status to a server. For example, by simply entering ping google.com, the command will check whether you're able to connect to Google and also measure the response time.

unzip

Use the zip command to compress your files into a zip archive, and use the unzip command to extract the zipped files from a zip archive.

vi

Vi IMproved, a programmers text editor. Vim is a word processor that is upward compatible with Vi. Can be used to edit all types of plain text.

ps

View all of the currently running processes

grep

View the contents of a file that match a pattern. It lets you search through all the text in a given file. To illustrate, grep blue notepad.txt will search for the word blue in the notepad file. Lines that contain the searched word will be displayed fully.

last

When executed last command will display the list of last logged in users into the system as an output in Linux Terminal.

ip

With the ip command, you can adjust the way a Linux computer handles IP addresses, network interfaces controllers (NICs), and routing rules. The changes also take immediate effect—you don't have to reboot.

xargs

Xargs reads arguments separated from standard input by spaces (possibly with an apostrophe, quotation mark, or backslash) or newline characters, and executes the command (the default / bin / echo) each time it reads an initial argument followed by some arguments from standard input. Blank lines from standard input are ignored.

passwd

You can use passwd command to change the password for self or any user, just through the command passwd if you want to change password for youself and passwd <user name> if you want to change password for particular user.

locate

You can use this command to locate a file, just like the search command in Windows. What's more, using the -i argument along with this command will make it case-insensitive, so you can search for a file even if you don't remember its exact name. To search for a file that contains two or more words, use an asterisk (*). For example, locate -i school*note command will search for any file that contains the word "school" and "note", whether it is uppercase or lowercase.

cut

a command for cutting out the sections from each line of files and writing the result to standard output. It can be used to cut parts of a line by byte position, character and field. Basically the cut command slices a line and extracts the text

apt

apt (Advanced Package Tool) is Linux command which helps user to interact with the packaging system

arp

arp command manipulates the System's ARP cache. It also allows a complete dump of the ARP cache. ARP stands for Address Resolution Protocol. The primary function of this protocol is to resolve the IP address of a system to its mac address, and hence it works between level 2(Data link layer) and level 3(Network layer).

at

at command is a command line utility that is used to schedule a command to be executed at a particular time in the future. Jobs created with at command are executed only once. The at command can be used to execute any program or mail at any time in the future. It executes commands at a particular time and accepts times of the form HH:MM to run a job at a specific time of day.

cron

automates the scheduled task at a predetermined time. It is a daemon process, which runs as a background process and performs the specified operations at the predefined time when a certain event or condition is triggered without the intervention of a user. Dealing with a repeated task frequently is an intimidating task for the system administrator and thus he can schedule such processes to run automatically in the background at regular intervals of time by creating a list of those commands using cron. It enables the users to execute the scheduled task on a regular basis unobtrusively like doing the backup every day at midnight, scheduling updates on a weekly basis, synchronizing the files at some regular interval. Cron checks for the scheduled job recurrently and when the scheduled time fields match the current time fields, the scheduled commands are executed. It is started automatically from /etc/init.d on entering multiuser run levels.

cat

cat (short for concatenate) is one of the most frequently used commands in Linux. It is used to list the contents of a file on the standard output (sdout). To run this command, type cat followed by the file's name and its extension. For instance: cat file.txt. (**look at examples on the main pdf**)

cd

change directory. cd command helps you to access particular directory or folder from the file system. You can also use cd .. command to go back to root.

dd

convert and copy files.

cp

copy files and directories. Ex: "cp item1 item2" would copy item1 into the file or directory item2. Ex: "cp item... directory" copies multiple items (either files or directories) into a directory.

mkdir

create (make) directories. Ex: "mkdir dir1" would create a single directory named dir1

curl

curl is a command line tool to transfer data to or from a server, using any of the supported protocols (HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP or FILE). curl is powered by Libcurl. This tool is preferred for automation, since it is designed to work without user interaction. curl can transfer multiple file at once.

file

determine file type and brief description of the file's contents

cal

displays a calendar of the current month

date

displays current time and date

tty

displays information related to terminal. The tty command of terminal basically prints the file name of the terminal connected to standard input. tty is short of teletype, but popularly known as a terminal it allows you to interact with the system by passing on the data (you input) to the system, and displaying the output produced by the system.

df

displays the current amount of free space your disk drives.

wget

download files from the internet with the help of the wget command. To do so, simply type wget followed by the download link. download works in background so that you can continue working on your task.

exit

ends a terminal session by closing the window

id

id command in Linux is used to find out user and group names and numeric ID's (UID or group ID) of the current user or any other user in the server. This command is useful to find out the following information as listed below: User name and real user id. Find out the specific Users UID. Show the UID and all groups associated with a user.

iptables

iptables is a simple Linux Terminal based firewall tool which helps manage both incoming and outgoing traffic using tables.

iwconfig

iwconfig command in Linux is like ifconfig command, in the sense it works with kernel-resident network interface but it is dedicated to wireless networking interfaces only. It is used to set the parameters of the network interface that are particular to the wireless operation like SSID, frequency etc. iwconfig may also be used to display the parameters, and the wireless statistics which are extracted from /proc/net/wireless.

jobs

jobs command will display all current jobs along with their statuses. A job is basically a process that is started by the shell.

ls

list directory contents

more

more command is used to view the text files in the command prompt, displaying one screen at a time in case the file is large (For example log files). The more command also allows the user do scroll up and down through the page.

mv

move/rename files and directories. The arguments in mv are similar to the cp command. You need to type mv, the file's name, and the destination's directory. For example: mv file.txt /home/username/Documents. To rename files, the Linux command is mv oldname.ext newname.ext

nano

nano is Linux command-line text editor just similar to Pico editor which many of you might have used for programming and other purposes. It is quite useful text editor with lots of features.

pwd

print name of current working directory. find out the path of the current working directory (folder) you're in. The command will return an absolute (full) path, which is basically a path of all the directories that starts with a forward slash (/). An example of an absolute path is /home/username.

dhclient

provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.

bg

resume a program's execution in the background

rev

rev command in Linux is used to reverse the lines characterwise. This utility basically reverses the order of the characters in each line by copying the specified files to the standard output. If no files are specified, then the standard input will read. rm: remove files and directories

route

route command in Linux is used when you want to work with the IP/kernel routing table. It is mainly used to set up static routes to specific hosts or networks via an interface. It is used for showing or update the IP/kernel routing table.

history

running history command is particularly useful if you want to review the commands you've entered before

scp

scp acronym for Secure Copy is the Linux command which can be used to copy files and directories between hosts on the network.

sed

sed = stream editor. It performs text editing on a stream of text, either a set of specified files or standard input. sed is given either a single editing command or the name of a script file containing multiple commands, and then it performs these commands upon each line in the stream of text.

awk

sed works for simple, oneline tasks rather than long scripts. awk and perl are better tools for larger tasks. awk's specific strength is its ability to manipulate tabular data. It resembles sed in that awk programs normally process text files line by line, using a scheme similar to the sed concept of an address followed by an action. need better explanation, effing clue what this means.

service

service command will display results of System V init scripts in the Terminal window.

sh

sh is the command name of the Bourne shell, the standard command language interpreter of Unix and many Unix-like operating systems, including Linux.

man

shows the manual for each command. For instance, entering man tail will show the manual instruction of the tail command.

sort

sort <file name> command will help you sort file or arrange any record in particular order generally according to their ASCII values.

su

su <username> command can be used to switch to another account right from the Linux Terminal window.

systemctl

systemctl may be used to introspect and control the state of the "systemd" system and service manager

tac

tac <file name> command will display the contents of the file in reverse orders as you can see in below screenshot.

tee

tee command reads the standard input and writes it to both the standard output and one or more files. The command is named after the T-splitter used in plumbing. It basically breaks the output of a program so that it can be both displayed and saved in a file. It does both the tasks simultaneously, copies the result into the specified files or variables and also display the result.

nc

the nc command runs Netcat, a utility for sending raw data over a network connection

ifconfig

used to configure network interface on the system.

kill

used to kill processes. This allows us to terminate programs. kill command sends processes signals. If you have an unresponsive program, you can terminate it manually by using the kill command. It will send a certain signal to the misbehaving app and instructs the app to terminate itself. There is a total of sixty-four signals that you can use, but people usually only use two signals,, SIGTERM = requests a program to stop running and gives it some time to save all of its progress. If you don't specify the signal when entering the kill command, this signal will be used. (refer to sheet for more info) SIGKILL = forces programs to stop immediately. Unsaved progress will be lost. Besides knowing the signals, you also need to know the process identification number (PID) of the program you want to kill. If you don't know the PID, simply run the command ps ux. After knowing what signal you want to use and the PID of the program, enter the following syntax, kill [signal option] PID.

less

view file contents. Specifically, a program to view text files with human-readable text.

watch

watch command in Linux is used to execute a program periodically, showing output in fullscreen. This command will run the specified command in the argument repeatedly by showing its output and errors. By default, the specified command will run every 2 seconds and watch will run until interrupted.

wc

wc command reads the file thrown with the command and displays word and line count of the file.

wpa_cli

wpa_cli is a text-based frontend program for interacting with wpa_supplicant.

wpa_passphrase

wpa_passphrase pre-computes PSK entries for network configuration blocks of a wpa_supplicant.conf file. An ASCII passphrase and SSID are used to generate a 256-bit PSK.


Conjuntos de estudio relacionados

IBM 3012 CH 14, 15, 17,18 Study Guide

View Set

Olds Maternal-Newborn nursing ch 29

View Set

**EXAM 3 Heart's Conduction System

View Set

possible OB test 2 questions from prep-u

View Set

Crime and Punishment - literary devices

View Set

Las asignaturas definiciones part 1

View Set