Important Linux Commands Working With Shell Lab - 2
Important Linux Commands Working With Shell Lab - 2
The actual command is always printed as command. Without this, nothing can
function.
Options without which the respective program cannot function are printed in
italics.
File Commands
File Administration
ls [option(s)] [file(s)]
If you run ls without any additional parameters, the program will list the contents of
the current directory in short form.
-l detailed list
-a displays hidden files
cp [option(s)] sourcefile targetfile
Removes the specified files from the file system. Directories are not removed by rm
unless the option -r is used.
Changes the current directory. cd without any parameters changes to the user's home
directory.
mkdir [option(s)] directoryname
The mode parameter has three parts: group, access, and access type. group accepts
the following characters:
u-user
g-group
o-others
For access, access is granted by the + symbol and denied by the - symbol.
r=read
w=write
x=eXecute — executing files or changing to the directory.
find [option(s)]
The find command allows you to search for a file in a given directory. The first
argument specifies the directory in which to start the search. which uses a database,
find scans the actual directory.
The cat command displays the contents of a file, printing the entire contents to the
screen without interruption.
System Commands
System Information
df [option(s)] [directory]
The df (disk free) command, when used without any options, displays information
about the total disk space, the disk space currently in use, and the free space on all the
mounted drives. If a directory is specified, the information is limited to the drive on
which that directory is located.
This command, when executed without any parameters, shows the total disk space
occupied by files and subdirectories in the current directory.
The command free displays information about RAM and swap space usage, showing
the total and the used amount in both categories.
-b=Output in bytes
-k=Output in kilobytes
-m=Output in megabytes
date [option(s)]
This simple program displays the current system time. If run as root, it can also be
used to change the system time. Details about the program are available in date.
Processes commands:
top [options(s)]
top provides a quick overview of the currently running processes. Press H to access a
page that briefly explains the main options to customize the program.
If run without any options, this command displays a table of all your own programs or
processes — those you started. The options for this command are not preceded by
hyphen.
You should still be able to stop such a runaway program by executing the kill command,
specifying the respective process ID (see top and ps).
kill sends a TERM signal that instructs the program to shut itself down. If this does
not help, the following parameter can be used:
-9 Sends a KILL signal instead of a TERM signal, with which the process really is
defeated by the operating system.
killall [option(s)] processname
This command is similar to kill, but uses the process name (instead of the process ID)
as an argument, causing all processes with that name to be killed.
To download a video file, simply run the following command. Where “VIDEO_URL” is the
url of the video that you want to download. First download youtube-dl from terminal.
# youtube-dl https://www.youtube.com/watch?v=iRYvuS9OxdA
Type the following command in a terminal to list all the avialable options.
# youtube-dl --help
Network commands:
netstat :
1. -a -all : Show both listening and non-listening sockets. With the –interfaces option,
show interfaces that are not up
2. # netstat -a | more : To show both listening and
non-listening sockets.
The ping command is the standard tool for testing the basic functionality of TCP/IP
networks. It sends a small data packet to the destination host, requesting an immediate
reply. If this works, ping displays a message to that effect, which indicates that the
network link is basically functioning.
-c
number Determines the total number of packages to send and ends after they have
been dispatched. By default, there is no limitation set.
-f
flood ping: sends as many data packages as possible. A popular means, reserved to
root, to test networks.
-i
value Specifies the interval between two data packages in seconds. Default: one
second
nslookup
The Domain Name System resolves domain names to IP addresses. With this tool,
send queries to information servers (DNS servers).
Telnet is actually an Internet protocol that enables you to work on remote hosts across
a network. telnet is also the name of a Linux program that uses this protocol to enable
operations on remote computers.
Shutdown linux
# shutdown -h now
The h option is for halt which means to stop. The second parameter is the time parameter.
"now" means that shutdown the system right away.
# shutdown
# shutdown now
# shutdown 13:20
# shutdown -p now #poweroff the machine
# shutdown -H now #halt the machine
# shutdown -r09:35 #reboot the machine at 09:35am
Hatl commands
#halt #halt the machine
# halt -p #poweroff the machine
# halt --reboot #reboot the machine
Restart linux
The shutdown command can be used to restart a system with the r option instead of the h
option. Usage is same as before. Just replace the h option with r option.
# shutdown -r +5 "Server will restart in 5 minutes. Please save your work."
All other logged in users will see a broadcast message in their terminal like this
[root@dhcppc1 ~]#
Broadcast message from root@dhcppc1
(/dev/tty1) at 21:35 ...
At this point a shutdown can be cancelled by calling shutdown with "c" option.
# shutdown -c
What is apt-get?
a powerful and free package management command line program, that is used to work
with Ubuntu’s APT (Advanced Packaging Tool) library to perform
o installation of new software packages,
o removing existing software packages,
o upgrading of existing software packages and even
o used to upgrading the entire operating system.
Vi editor: provides three operating modes. In command mode keys are interpreted as command
elements. Insert mode interprets all keys as text entries and last line mode is used for more complex
commands, which are entered in the last line.
Good luck!!