আমার পঠিত ব্লগ সমুহ

বুধবার, ২০ জুন, ২০১২

Linux Commands


 Modes of Operation

The linux operating system used for the PARTICLE DAQ system can be used either in a terminal mode where you type commands or in a Windows Explorer style graphical user interface (GUI).

The Explorer-like GUI can be used for file manipulation functions (e.g., copying a file to a floppy) or deleting or moving files on the disk.  It cannot be used to run the PARTICLE DAQ itself.

To begin using the Explorer-like GUI, double click on the icons on the Desktop.  For the most part, Explorer mode will be familiar from Windows or MAC OS, so with a few exceptions, this information will not focus on this.  Where something is much more easily done from Explorer mode, it will be highlighted here.

To begin working in the terminal mode, you will need to open a terminal.  This can be accomplished by clicking on the terminal icon in the bottom icon bar, by using the main menu (footprint icon in lower left of bottom icon bar) System Tools -> New Terminal.
Here is a list of basic linux commands. This list of linux commands is not complete as there are many more linux commands available. However, it should make a good start for a beginner or intermediate linux administrator /linux user. All linux commands in this list include examples to demonstrate how the actual linux command works. If you do not find an answer to your question on this page or you need extra help, feel free to ask us on our new Linux Forum. We will be more than happy to help you with your Linux questions there.

A
§  alias - create names or abbreviations for commands
§  apropos - search the manual page names and descriptions
§  at [man page] - queue, examine or delete jobs for later execution
B
§  bc [man page] - An arbitrary precision calculator language
C
§  cal - displays a calendar
§  cat [man page] - concatenate files and print on the standard output
§  cd - change directory
§  chgrp [man page] - change group ownership
§  chmod [man page] - change file access permissions
§  cksum [man page] - checksum and count the bytes in a file
§  cp [man page] - copy files and directories
§  csplit [man page] - split a file into sections determined by context lines
D
§  date [man page] - print or set the system date and time
§  dd [man page] - convert and copy a file
§  du [man page] - estimate file space usage
E
§  egrep [man page] - print lines matching a pattern
§  export - set an environment variable
F


§  fgrep [man page] - print lines matching a pattern
§  find [man page] - search for files in a directory hierarchy
§  fold [man page] - wrap each input line to fit in specified width
G
§  grep [man page] - print lines matching a pattern
H


§  head [man page] - output the first part of files
I
J
§  join [man page] - join lines of two files on a common field
K
L
§  logrotate [man page] - rotates, compresses, and mails system logs
§  ls [man page] - list directory contents
M
§  mkdir [man page] - make directories
§  mv [man page] - move (rename) files
§  mount [man page] - mount a file system
N
§  nl [man page] - number lines of files
O
§  od [man page] - dump files in octal and other formats
P
§  pwd [man page] - print name of current/working directory
Q
R
§  rgrep [man page] - print lines matching a pattern
§  rm [man page] - remove files or directories
S
§  scp - secure copy (remote file copy program)
§  ssh - OpenSSH SSH client (remote login program)
T
§  tail [man page] - output the last part of files
§  tar [man page] - The GNU version of the tar archiving utility
§  tee [man page] - read from standard input and write to standard output and files
§  time [man page] - run programs and summarize system resource usage
§  touch [man page] - change file timestamps
V
§  vim - Vi IMproved, a programmers text editor
W
§  watch [man page] - execute a program periodically, showing output fullscreen
§  wc [man page] - print newline, word, and byte counts for each file
§  whoami [man page] - print effective userid
X


Modes of Operation

The linux operating system used for the PARTICLE DAQ system can be used either in a terminal mode where you type commands or in a Windows Explorer style graphical user interface (GUI).

The Explorer-like GUI can be used for file manipulation functions (e.g., copying a file to a floppy) or deleting or moving files on the disk.  It cannot be used to run the PARTICLE DAQ itself.

To begin using the Explorer-like GUI, double click on the icons on the Desktop.  For the most part, Explorer mode will be familiar from Windows or MAC OS, so with a few exceptions, this information will not focus on this.  Where something is much more easily done from Explorer mode, it will be highlighted here.

To begin working in the terminal mode, you will need to open a terminal.  This can be accomplished by clicking on the terminal icon in the bottom icon bar, by using the main menu (footprint icon in lower left of bottom icon bar) System Tools -> New Terminal. 

The Manual (terminal mode)

man                                This command brings up the online Unix
manual. Use it on each of the commands below.

For Example:   
man pwd                        You will see the manual for the pwd command.



Accessing files in Folders (Directories) in terminal mode

pwd                                Shows what directory (folder) you are in.
In Linux, your home directory is /home/particle

·       Let's suppose you have several data files (data1, data2 ... etc.) in a directory called muondata.
·       Then suppose the directory muondata is an entry in your main home directory, /home/particle .
·       If you are in your home directory (where terminals start) and type pwd, you will see /home/particle.
·       If you were in the muondata directory, pwd would give you /home/particle/muondata instead    
·       The last slash after a directory name is optional.

As you can see, each slash (/) indicates another sub-directory.
cd                                  Changes directories.

Examples of relative movement among directories:
cd muondata                Moves down from your current directory
into the muondata sub-directory


cd ..                            Moves up one directory (yes, include the
two little dots) 

You can also move directly into directories
cd /home/particle/muondata
                   Moves from ANY directory into the muondata
sub-directory of your home directory.

cd ~               Takes you back to your home directory
(/home/particle)

Making or Removing a Directory (terminal mode)

mkdir dirName            Creates a directory with name dirName.

For Example:
mkdir temp             Creates the directory temp.


rmdir dirName      Removes a directory dirName.

For Example:
rmdir temp                  Removes the directory temp.


Looking at or Finding your Files (terminal mode)

ls                                  Lists files.

If you add -al after ls it will give more details for each file. Such as, size, permissions, owners, dates etc.

ls al                          You'll see a huge list of files that you can't see with the 'ls' command alone and lots of details.

If you see such a long list of files that they scroll off the terminal screen, one way to solve the problem is to use:

ls -al |more       Shows one screen of file names at a time.

less data1         Dumps the contents of the data1 file to your screen with a pause at each line so you don't miss any contents as they scroll. You may move through the file using page up, page down, home and end keys.  When done with less you use the q key to get back to the main terminal.

whereis data1      Shows you the location of the data1 file.



Altering your Files

rm data1                      Deletes the file data1 in the current directory. 

rm -i muon*                Removes all of your muon data files
(careful!!  rm * will remove ALL your files) 
The "-i" makes the computer prompt before removing each file.  If you really want to work without a net, omit the "-i".

cp data1 newdata/    will copy the file data1 to the directory newdata (assuming it has already been created)

mv data1 newdata/    moves the file data1 to the folder newdata and deletes the old one.








CommandExampleDescription
catSends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping.
cat .bashrcSends the contents of the ".bashrc" file to the screen.
cdChange directory
cd /homeChange the current working directory to /home. The '/' indicates relative to root, and no matter what directory you are in when you execute this command, the directory will be changed to "/home".
cd httpdChange the current working directory to httpd, relative to the current location which is "/home". The full path of the new working directory is "/home/httpd".
cd ..Move to the parent directory of the current directory. This command will make the current working directory "/home.
cd ~Move to the user's home directory which is "/home/username". The '~' indicates the users home directory.
cpCopy files
cp myfile yourfileCopy the files "myfile" to the file "yourfile" in the current working directory. This command will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning if it exists.
cp -i myfile yourfileWith the "-i" option, if the file "yourfile" exists, you will be prompted before it is overwritten.
cp -i /data/myfile .Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt before overwriting the file.
cp -dpr srcdir destdirCopy all files from the directory "srcdir" to the directory "destdir" preserving links (-p option), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another directory.
dddd if=/dev/hdb1 of=/backup/Disk duplicate. The man page says this command is to "Convert and copy a file", but although used by more advanced users, it can be a very handy command. The "if" means input file, "of" means output file.
dfShow the amount of disk space used on each mounted filesystem.
lessless textfileSimilar to the more command, but the user can page up and down through the file. The example displays the contents of textfile.
lnCreates a symbolic link to a file.
ln -s test symlinkCreates a symbolic link named symlink that points to the file test Typing "ls -i test symlink" will show the two files are different with different inodes. Typing "ls -l test symlink" will show that symlink points to the file test.
locateA fast database driven file locator.
slocate -uThis command builds the slocate database. It will take several minutes to complete this command. This command must be used before searching for files, however cron runs this command periodically on most systems.
locate whereisLists all files whose names contain the string "whereis".
logoutLogs the current user off the system.
lsList files
lsList files in the current working directory except those starting with . and only show the file name.
ls -alList all files in the current working directory in long listing format showing permissions, ownership, size, and time and date stamp
moreAllows file contents or piped output to be sent to the screen one page at a time.
more /etc/profileLists the contents of the "/etc/profile" file to the screen one page at a time.
ls -al |morePerforms a directory listing of all files and pipes the output of the listing through more. If the directory listing is longer than a page, it will be listed one page at a time.
mvMove or rename files
mv -i myfile yourfileMove the file from "myfile" to "yourfile". This effectively changes the name of "myfile" to "yourfile".
mv -i /data/myfile .Move the file from "myfile" from the directory "/data" to the current working directory.
pwdShow the name of the current working directory
more /etc/profileLists the contents of the "/etc/profile" file to the screen one page at a time.
shutdownShuts the system down.
shutdown -h nowShuts the system down to halt immediately.
shutdown -r nowShuts the system down immediately and the system reboots.
whereisShow where the binary, source and manual page files are for a command
whereis lsLocates binaries and manual pages for the ls command.

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন