Ubuntu Linux Absolute Beginners Command Quick Reference
-
Upload
nguyen-phuong -
Category
Documents
-
view
229 -
download
0
description
Transcript of Ubuntu Linux Absolute Beginners Command Quick Reference
-
Ubuntu Linux Absolute Beginners Command Quick Reference
Getting Helphttp://www.ubuntu.com/support http://ubuntuforums.org/ http://ubuntuguide.org http://linuxquestions.org/Pressing F1 will open help for the current applicationman any_command Display the man page for the given
command, e.g. man cp press q to exitinfo any_command As man (may contain more information)apropos subjector man -k subject
Display related man pages for the given subject e.g. apropos copy file
User/group Adminadduser name Create a new user called namepasswd username Give username a new passwordusermod -a -G grp user Add user to group grpgroupadd grp Create group grpsudo command Run command as superuser (root)sudo -s Switch to the root (superuser) shellsu username Switch to username's shellexit Stop being the superuser
File Handlingls -l List files in the current directory in long formatls -F list files in the current dir and show the file typels -a list all (including hidden) files in the current dircd name change directory /path/file indicates from
root, path/file indicates relative.cd change to the current users home directory,
use ~ elsewhere to reference users home dirrm name Remove file or directory called namerm -rf name Caution Dangerous Command.
Completely remove a directory, all contained files and subdirectoriesExtremely dangerous when used with sudo
cp file dest copy file to destmv file dest Move file to destcat file Display the filemore file Display the file one line at a timeless file Display the file use to move & q to exithead file Display the first 10 lines of filehead -20 file Display the first 20 lines of filetail file Display the last 10 lines of filetail -20 file Display the last 20 lines of filetouch file Update the access and modification times of
file to the current time.
Finding Files / Text Within Filesfind / -name fname Starting in the root directory, look
for a file named fnamefind / -name *fname* Starting in the root directory look
for a file name containing fnamelocate fname Find a file called fname using the
locate command updatedb (next) should have already been done
updatedb Create or update the files databasewhich exec Display the directory containing the
executable exec e.g which cp
grep texttofind /dir Starting with the /dir directory look for and list files containing the string texttofind
grep -c findtext files Count how many times findtext appears in files
Installing SoftwareMost software installation will require superuser (root) permissions, precede the following coomands with sudo when required.
Using apt
apt-get update Resynchronize the package index files from their sources
apt-get install pkg Install pkg Install multiple packages by leaving a space between the names e.g.apt-get install pkg1 pkg2
apt-get remove pkg Remove pkg as aboveapt-get upgrade Upgrade all installed packages to
the latest available versionapt-cache search string Search all available package lists
for names & descriptions matching string
Using dpkg (Installing .deb files)
dpkg -i file.deb Install file.debdpkg -r file.deb Remove file.deb leaving the
configuration filesdpkg -P file.deb Remove file.deb including the
configuration filesdpkg-reconfigure pkg Reconfigure pkg
Uncompressing files
tar -zxvf arch.tar.gz Uncompress arch.tar.gztar -jxvf arch.tar.bz2 Uncompress arch.tar.bz2
System Informationlshw or lspci orlsusb or report-hw
List Hardware, pci, usb devices add -v for verbose output (best run as su)
uname -r Display the kernel versiondmesg Display system diagnostic messages
append >file to output to fileblkid Display Filesystem UUIDs
Starting and Stoppingshutdown -h now Shutdown nowhalt As aboveshutdown -r now Shutdown and reboot nowreboot As aboveshutdown -r 5 Shutdown and reboot in 5 minutesstartx Start the X server
V1.5219/07/2008
-
Ubuntu Linux Absolute Beginners Command Quick Reference
File PermissionsOwner Group Others
d r w x r w x r w x
File Permissions are altered by issuing the chmod command followed by a 3 digit number, the first digit relating to the owner, the second the group and the third for others. this number is achieved by adding the values together for the required permissions.
E.g. To add owner RWX, Group RW, Others Read:chmod 764 filenameOwner = R(4) + W(2) + X(1) = 7Group = R(4) + W(2) = 6Others = R(4) = 4chmod +x file Make the file executablechown user file Change the owner of file to userchgrp grp file Change the group of file to grp
Config FilesMake a backup of any file before editing by issuing a cp origfilename backupfilename command/etc/profile System wide environment
variables for all users/etc/fstab List of devices and their mount
points/etc/cron. hourly daily weekly monthly
All scripts contained within these sub directories are run at the set intervals
crontab -e Edit current users crontab file/etc/hosts A list of all known host names
and IP addresses on the machine
/boot/grub/menu.lst The configuration of the grub boot loader including the items listed at startup.
/etc/resolv.conf Specifies IP addreses of DNS servers
/etc/dhcp3/dhclient.conf Configuration information for the DHCP client
/etc/X11/xorg.conf Configuration for the X-Server
Processesps -e show all processes running on the systemps -ef Show all processes running on the system
with users who own the processps -elf As above showing the 'nice' valuepstree Show all processes running on the system
in a tree formatpstree -pu As above with process IDs (PIDs) and
usernameskill 12345 Kill the process with the PID of 12345renice +1 12345 renice the process with id 12345 to a
value of +1 over its current value. +20 = lowest nice value (will only run when no other process is active), -20 = highest nice value. Must be su to reduce the nice value.
GeneralAppending > filename to any_command will direct the output to the given filename
Pipes & Chainscmd1 | cmd2 output of cmd1 is directed to cmd2 (Pipe)cmd1 && cmd2 Execute cmd1 then cmd2 (Chain)
Operating as root (su)You can do serious damage to your OS when operating as su. Take care with what you are doing, ensure you fully understand what the command you are about to issue will do before hitting the return key
If a permission denied or command not found message is received after issuing a command then you may need su privileges to perform the operation. Precede the command with sudo to continue
Stringsstrings containing spaces generally either need to be enclosed in quotes e.g. text string or the spaces escaped with a \ e.g.text\ string
Home FolderStart any path with ~ to reference the current users home folder.e.g cp /dir/dir/dir/file ~/fileType cd on its own to return to your home dir.
X-Shortcuts (Desktop)alt+F2 Display the run dialogalt+F6 Switch between windows of the
same applicationalt+F9 Minimize the current windowalt+F10 Maximize the current windowCtrl+alt+F? Switch to another sessionCtrl+alt+Backspace Restart the X-ServerCtrl+alt+Cursor Switch workspaceCtrl+alt+Tab Switch between Windows
Compiz-Fusionctrl+alt+ or Rotate cubectrl+alt+left click Free rotate cubectrl+alt+ Unfold cubeshift+alt+ Window pickeralt+tab Window switchsuper+tab Ring switcheralt+F7 Move windowshift+F10 Slow animationsctrl+alt+D Show desktopsuper+s Select windowsuper+t Tab groupsuper+ or Change tabsuper+g Group windowssuper+u Ungroup windowssuper+r Remove groupsuper+c Close groupsuper+x Ignore group
Execute (1)Write (2)Read (4)
File Type- = Filed = Directoryl = Link
V1.5219/07/2008