Sei sulla pagina 1di 3

Entering Commands ACTION LINUX DOS COMMENTS Get command help. man <some command> help, command /?

man syst em is well-developed and most apps have a man file. Find related commands. apropos <some search string> No DOS equivalen t. Flip through entered commands. Arrows ^ and v Arrows ^ and v Show command history. history doskey /h Set a command alias. alias name=command doskey name=command Use ~/.b ashrc to set permanently in *nix. Clear the screen. clear, ctrl-l cls Trap ctrl-break or trap signals. trap break on Starting and Quitting ACTION LINUX DOS COMMENTS Start Windows or X-Windows. startx win Reboot system. shutdown -r now reboot Exit the shell. exit, exit 0 exit, exit0 Get operating system or shell version. uname -a, cat /etc/issue ver Working with Disks ACTION LINUX DOS COMMENTS Check and repair drive file system. fsck, debugfs scandisk, defrag Show disk usage. du -s chdisk Tool to partition a hard drive. fdisk fdisk Mount a drive letter to a folder/directory on your hard drive. mount subst X: C:\directory\path Format a drive file system. mke2fs format Setting the Environment ACTION LINUX DOS COMMENTS List environment variables. set, env set Set an environment variable. export variable=value, setenv, or variable=value set variable=value Show the contents of an environment variable. echo $variable echo %variable% Display text on screen. echo text echo text Display the system search path. echo $PATH PATH Append a directory to the system search path. PATH=$PATH:/dir PATH %PATH%;C:\D IR Setting the path allows you to run commands without thinking about where their executable file is. Set the style of the command prompt. export PS1='\h(\u)\W> ' PROMPT $p$g Much more complexity is possible in both flavors of OS, here. Getting System Info ACTION LINUX DOS COMMENTS Show and set the system date and time. date date, time Show free memory on system. free, top mem List information about running processes. ps -aux tasklist Print computer's name. hostname hostname, net name hostname is DNSrelated, whereas the Windows net name command shows netbios info. Show system info. lsdev, procinfo msd Lsdev and procinfo do not work o n Linux VPSs sometimes due to the way disks are provisioned. Working with Files and Directories ACTION LINUX DOS COMMENTS Change directory. cd cd Store directories for reference. cd -, pushd /path/to/target, popd pushd, popd Pushd and popd are available for newer Windows versions. List directory contents with some detail. ls -l (or use ls -lF)(-a all fil es) dir The "bare" directory list commands are inherently different in d isplay characteristics. List directory contents in compact mode. ls dir /w List directory contents, oldest files first. ls -tr dir *.* /o-d List files and size. ls -ls dir *.* /v /os Notice you are stringing togethe r args in Linux after the dash, but that you have to put in additional slashes a

nd args in DOS. List size of directory contents. du -h | sort -rn, du -hsc * --block-size =M (treesize) Du or diskusage is common, but the switches will be diff erent so do a "man du" to find out more in your *nix. Treesize is an excellent G UI version of du for Windows. List directory contents recursively. ls -R dir /s List including hidden files. ls -a dir /aa Create a semi-graphical "tree" view of folders and sub-folders. tree tree Use tree with more to get page-by-page output, and space-bar through the pages. I.e.: $ tree | more Make a new directory. mkdir mkdir, md Create a file or directory link. ln (assign, subst) Neither assign n or subst are really much like ln. Remove a directory. rmdir rmdir, rd Display current location. pwd chdir Remove a file. rm -iv del, erase, rmdir /s Remove directory and its contents. rm -R deltree Deltree is Win 95. Copy a file. cp -piv copy Of course you can just cp a file in Linux, as we ll. Copy a directory and all its subcontents. cp -R xcopy Rename or move a file. mv -iv rename, move Show the contents of a file. cat type Show the contents of a file, one page at a time. more more Sort data alphabetically or numerically. sort sort Find a string in a file. grep find, findstr Compare two files and show differences. Also see comm, cmp, mgdiff and tkdiff. diff comp, fc Set or change file permissions. chmod attrib DOS has hidden switch; use mv to .somename to make a file hidden in *nix. Print a file. lpr print Line mode editor ed edlin Edit a text file. [editor] filename - where editor can be nano, pico, vi, emacs etc. edit filename.txt In *nix, editors are a religion because the are used so heavily for systems administration tasks. Pico was the editor th at came with the Pine mailer, and nano is a standalone pico variant. Many swear by simple vi or complex emacs, though. Backup and Restore ACTION LINUX DOS COMMENTS Backup or Restore files. tar -cvf, tar -xvf, mdir, mcopy, ditto, cpio backup, restore Backup files to a folder. tar -cvf /path/to/storage files backup files X:\ Restore files from a folder. tar -xvf /path/to/storage files restore X:\ file s Compress or uncompress files and folders. tar, zip, gzip, bzip pkzip Note, tar just concatenates files together for easy manipulation, and is often u sed before compression. Batch and Shell Scripting ACTION LINUX DOS COMMENTS Call another script from within a batch file or shell script. source somescrip t, . somescript, sh somescript call command /c (or cmd) somescript Scheduling ACTION LINUX DOS COMMENTS Schedule a command or script to run on a schedule. crontab -l, crontab -e at Network Commands ACTION LINUX DOS COMMENTS Send icmp packets to a network host. ping ping Show routes and router hops to given network destination. traceroute tracert Display or configure network interfaces. ifconfig ipconfig, winipc

fg You cannot configure the network from the command line in Windows, like you can with ifconfig in *nix. Use Control Panel. Get netbios or dns info for the host. nslookup, dig nbtstat NetBIOS is a Win dows and DOS affair. Print the current routing table. route -n route print List startup background services or daemons. chkconfig --list |grep on net start service some-service start|stop net start|stop some-service Show mounted or connected shares and filesystems. df net share, net u se Communications ACTION LINUX DOS COMMENTS Send a messenger popup message to a Windows PC. smbclient -M win-hostname net send win-hostname "some message" Send message to another *nix user. talk Working with Users ACTION LINUX DOS COMMENTS List who is logged in. who List how many users are currently logged in. who | wc -l Show the current user account. whoami set There is a whoami command for Wi ndows available in the Resource Kit. Or, you can use set to list the environment variables, of which the username is one. Show who is logged in and what they are doing. w net session Show a list of a user's processes. ps -u account_name (Task Manager)

Potrebbero piacerti anche