Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

Linux_Commands

Uploaded by

yasir latif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Linux_Commands

Uploaded by

yasir latif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Linux Console commands

System Information Commands:

Command Description
pwd print working directory, i.e. display the name of my current
directory on the screen
hostname Print the name of the local host (the machine on which
you are working). Use netconf ( as root) to change the name
of machine
whoami Print my login name
id username print user id(uid) and his/her group id(gid), effective id (if
different than the real id) and the supplementary group
date Print or change the Operating system date and time. E.g. ,
change the date and time to 2004-11—20 23:57 using this
command
date 112023572004
To set the hardware clock from the system clock, use the
command (as root) setclock
time Determine the amount of time that it takes for a process,
to complete + other info. Don’t confuse it with date
command. E.g. I can find out how long it takes to display
a directory contents using :
time ls
who Determine the users logged on the machine
rwho –a Determine the users logged on your network. The rwho
services must be enabled for this command to run if it isn’t
, run setup as root to enable “rwho”
finger user_name System info about a user. Try : finger root
last shows listing of users last logged –in on your system
uptime Amount of time since last reboot
ps Print status. List the processes currently run by the
current user.
ps axu |more List the process currently running, even those without the
controlling terminal, together with the name of the user
that owns each process.

top Keep listing the currently running process, sorted by cpu


usage. In KDE , you can get GUIbased Ktop from “K”
menu under “System” –“Task manager”(or by executing
ktop” in an X-terminal).
uname –a Info on your server
free Memory info (in Kilobytes)
df – h disk free , Print disk info about all the filesystems(in
human readable form)
du /-bh | more disk usage, Print detailed disk usage for each
subdirectory starting at root (in human legible form)
cat /proc/cpuinfo CPU info. Note that the file files in the /proc directory are
not real files .They are hooks to look at information
available to the kernel.
cat /proc/interrupts List the Interrupts in use
cat /proc/version Linux version and other information
cat /proc/filesystems Show the types of filesystems currently in use.
cst /etc/printcap Show the setup of printers
lsmode (as root) Show the kernel modules currently loaded.
set|more Show the current user environment
echo $ PATH Shows the content of the environment variable “PATH”.
This command can be used to show other environment
variables as well. Use “set” to see the full environment.
dmesg Print the look message .( it displays the file
:/var/log/dmesg)

Basic Operations commands:

any command Display brief help on a command (works with most


help |more commands). “Help” works similar to DOS “/h” switch. The
“more” pipe is needed if the output is longer than one
screen
ls List the content of the current directory. similar to DOS
“Dir”.under Linux , the command “Dir” is an alias to ls.
ls -al|more List the content s of the current directory, all files (also
those starting with a dot), and in along form. Pipe the
output through the “more” command, so that the display
pauses after each screenful.
cd directory Change the directory. Using “cd” without the directory
name will take you to your home directory. “cd” will take
you to your previous directory and is a convenient way to
toggle b/w two directories
cd source copy files
destination
mcopy source Copy a file from/to a DOS filesystem (no mounting
destination necessary). E.g. mcopy a:/autoexec.bat -/junk. See man
mtools for a related commands: mdir, med, mren, mmove,
mdel, mmd, mrd, mformat…
mv source Move or rename files. The same command is used for
destination moving and renaming files and directories.
rm files Remove (delete) files. You must own the file in order to be
able to remove it.
mkdir directory Make a new directory.
rmdir directory Remove an empty directory.
rm –r files (Recursive remove ) remove files, directories, and their
subdirectories. Careful with this command as root you can
easily remove all files on the system with such command
executed o the top of your directory tree. And there is no
undelete in Linux (yet). But if you really wanted to do
it(reconsider), here is how (as root) :
rm –rf /*
cat filename |more View the content of a text file called “filename”, one page
a time. The “|” is the pipe symbol (on many American
keyboards it shares the key with “/”) The pipe makes the
output stop after each screenful. For long files, it is
sometimes convenient to use the commands head and tail
that display just the beginning and the end of the file. If
you happened to use “Cat” a binary file and your terminal
displays funny characters afterwards, you can restore it
with the command “reset”
less filename Scroll through a content of a text file. Press q when doe.
“Less” is roughly equivalent to “more” , the command you
know from DOS, although very often “less” is more
convenient than “more”
pico filename Edit a text file using the simple and standard text editor
called pico. You may use vi editor too.
pico –w filename Edit a text file while disabling the long line wrap. Handy for
editing configuration files.
E.g. /etc/fstab.
lynx file.html View an html file or browse the net from the text mode.
tar –zxvf Untar a tarred and compressed tarball (*.tar.gz or *.tgz)
filename.tar.gz that you downloaded from the Internet.
tar –xvf filename.tar Untar a tarred but uncompressed tarball (*.tar).
gunzip filename.gz Decompress a Zipped file (*.gz or *.z) Use gzip (also zip
or compress) if you wanted to compress files.
bunzip2 Decompress a file (*.bz2) zipped with b zip2 compression
filename.bz2 utility. Use for big files.
Unzip filename. Zip Decompress a file (*.zip) zipped with a compression utility
compatible with PKZIP for DOS.
find / -name Find the file called “filename” on your filesystem starting
“filename” the search from the toot directory “/”. The “filename” may
contain wildcards (*.?).
locate filename Find the file name of which contains the string “filename”.
Easier and faster than previous command but depends on
a database that normally rebuilds at night.
pine A good text mode mail reader. Another good and standard
one is “elm”. Your Netscape mail will read the mal from
your Internet account. Pine will let you read the “local”
mail. E.g . the mal your son or a boss process sends to
you from a computer on your home ne twork.
talk username Talk to another user currently logged on your machine (or
use “talk username@machinename” to talk to a user on a
different computer). To accept the invitation to the
conversion, type the command “talk username2”. If
somebody is trying to talk to you and disrupts your works.
You may use the command “mesg n” to refuse accepting
messages. You may want to use “who” or “rwho “ to
determine the users who are currently logged –in.
me Launch the “Midnight commander” file manager (looks like
“Norton Commander” for Linux).
telnet server Connect to another machine using the TELNET protocol.
Use a remote machine name or IP address. You will be
prompted or your login name and password—you must
have an account on the remote machine to login Telnet
will connect you to another machine and let you operate
on it as if your were sitting at its keyboard (almost). Telnet
is not very secure-everything you type goes in open text,
even your password!
rlogin server Remote login. Connect to another machine. The login
name/password from your current session is used: if it
fails you are prompted for a password.
rsh server Remote shell. Yet another way to connect to a remote
machine. The login name/password from your current
session is used; if it fails you are prompted for a
password.
ftp server Ftp another machine. (There is also neftp which adds
extra features and gftp for GUI). Ftp is good for copying
files to/from a remote machine . Try user “anonymous” if
you don’t have an account on the remote serer. After
connection, use “?” to see the list of available ftp
commands. The essential ftp command are : ls (see the
files on the remote system, ASCII ,binary(set file transfer
mode to either text or binary, important that you select the
proper one), get(copy a file from the remote system to the
local system),mget (get many files at once),put(copy a file
from the local system to the remote system), mput(put
many files at once),bye(disconnect..
Mincom Mincom program (looks like “Procomm for Linux).
/program _name Run an executable in the current directory, which is not on
your PATH.
startx Start an X-Windows server and the default windows
manager. Works like typing “win” under DOS with Win3.1,
95, 98.
stratx--:1 Start another X-windows Session on the display 1 (the
default is opened on display 0). You can have several GUI
terminals running concurrently. Switch b/w them using
<Ctrl><Alt><F7>, <Ctrl><Alt><F8>, etc.
xterm (in X terminal) Run a simple X-Windows terminal. Typing
exit to close it
gimp (in X terminal) A humble looking but very powerful image
editor. Takes some learning to use m but it is great for
artist. Use your mouse right button to get local menus.
netscape (in X terminal) Run netscape (requires a separate
Netscape Installation). Also, when not connected to the
network, Netscape likes to refuse to do anything (looks
like it hanged)-it revives when you connect.
shutdown –h now Shut down the system. Same as halt
shut down –r Reboot the system Same as reboot.
man topic Display the contents of the system manual pages *help)
on the topic. Try “man a” first. Press “q” to quit the viewer.
The command “info topic” works similar and may contain
more up-to-date information. Manual pages can be hard
to read. Try “any_command help” for short, easy to digest
help on a command. If more info needed , have a look to
the directory /usr/doc
apropos topic Give me the list of the commands that have something to
do with my topic.

Process control commands:

ps Print status. Display the list of currently running process


with their process IDs (PID) numbers. Use “ps axu” to see
all process currently running on your system. Use “top” to
keep listing process currently running .
fg PID Bring a background or stopped to the foreground .
bg PID Send the process to the background. Opposite to fg. The
same can be accomplish with <Ctrl>z
kill PID Force a process shutdown. First determine the PID of the
process to kill using ps.
Killall Kill Program(s) by name.
program_name

Basic Administration Commands:

setup (as root) Configure, mouse, soundcard, keyboard, X-


Windows, System services.
adduser user_name Create a new account (you must be root). E.g.
adduser Abdul
Abdul
Don’t forget to set up the password for the new user in
next step. The user home directory is /home/user_name
useradd user_name Same as above
userdel user_name Remove an account (you must be root). The user’s home
directory must be dealt with separately.
groupadd Create a new group on your system. Non –essential on a
group_name home machine with a small of users.
passwd Change the password on your current account. As a root
you can change the password for any user using :
passwd user_name
chmod perm Change mode. Change the file access permission for the
filename file you own (unless you are root in which case you can
change any file). You can make a file accessible in three
modes: read(r), write (w), execute (x) to three classes of
users. Owner (u) members of the same group as the
owner (g), others on the system (o). Check the current
access permission using
ls –l filename
if the file is accessible to all users in all mdes it’ll shows:
rwxrwxrwx
The first triplet shows the file permission for owner of the
file, the second for his/her group, the third for others. A
“no” permission is shown as “-“.
E.g. this command will add the permission to read the file
“junk” to all
(user+group+other):
chmod a+r junk
This command will remove the permission to execute the
file junk from others:
chmod o -x junk
chown Change the file owner and group.
new_ownername You should use these two commands after you copy a file
filename for use by somebody else.
chgrp
new_groupname
filename
su Substitute user id. Assume the superuser (root) identity
(you will be prompted for the password. Type “exit” to
return you to your previous login. Don’t habitually work on
your system as root. The root account is for administration
and the su command is to ease your access to the
administration account when you require it.
lsmode List all the currently loaded kernel modules.
modprobe –l|more List all the modules available for your kernel.
rmmod (as root, not essential) Remove the module_name form
module_name the kernel.
fdisk (as root) Linux hard drive partitioning utility .Similar to
DOS.

Networking commands:

ping machine name Check if you can contact another machine (give the
machine’s name or IP), press <Ctrl> C when done.
route –n Show the routing table.
ifconfig <as root) Display info on the network interfaces currently
active. (Athernet, ppp, etc). Your first Ethernet shows up
as eth0, second eth1, etc. first ppp over modems as ppp0,
second ppp1, etc. the “lo” is the”loopback only” interface
which should be always active. Use the option (see
ifconfig help) to configure the interfaces.
netstat |more Display a lot (too much?) info rmation on the status of your
network.

Compile By
Abdul Khalique, Karachi
bc020200605@vu.edu.pk

You might also like