Você está na página 1de 11

mkdir - make directories Usage mkdir [OPTION] DIRECTORY Options Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too. -m, mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask -p, parents no error if existing, make parent directories as needed -v, verbose print a message for each created directory -help display this help and exit -version output version information and exit cd - change directories Use cd to change directories. Type cd followed by the name of a directory to access that directory.Keep in mind that you are always in a directory and can navigate to directories hierarchically above or below. mv- change the name of a directory Type mv followed by the current name of a directory and the new name of the directory. Ex: mv testdir newnamedir pwd - print working directory will show you the full path to the directory you are currently in. This is very handy to use, especially when performing some of the other commands on this page rmdir - Remove an existing directory rm -r Removes directories and files within the directories recursively. chown - change file owner and group Usage chown [OPTION] OWNER[:[GROUP]] FILE chown [OPTION] :GROUP FILE chown [OPTION] --reference=RFILE FILE

Options Change the owner and/or group of each FILE to OWNER and/or GROUP. With --reference, change the owner and group of each FILE to those of RFILE. -c, changes like verbose but report only when a change is made -dereference affect the referent of each symbolic link, rather than the symbolic link itself -h, no-dereference affect each symbolic link instead of any referenced file (useful only on systems that can change the ownership of a symlink) -from=CURRENT_OWNER:CURRENT_GROUP change the owner and/or group of each file only if its current owner and/or group match those specified here. Either may be omitted, in which case a match is not required for the omitted attribute. -no-preserve-root do not treat `/' specially (the default) -preserve-root fail to operate recursively on `/' -f, -silent, -quiet suppress most error messages -reference=RFILE use RFILE's owner and group rather than the specifying OWNER:GROUP values -R, -recursive operate on files and directories recursively -v, -verbose output a diagnostic for every file processed The following options modify how a hierarchy is traversed when the -R option is also specified. If more than one is specified, only the final one takes effect. -H -L -P if a command line argument is a symbolic link to a directory, traverse it traverse every symbolic link to a directory encountered do not traverse any symbolic links (default)

chmod - change file access permissions Usage chmod [-r] permissions filenames r Change the permission on files that are in the subdirectories of the directory that you are currently in. permission Specifies the rights that are being granted. Below is the different rights that you can grant in an alpha numeric format.filenames File or directory that you are associating the rights with Permissions u - User who owns the file. g - Group that owns the file.

o - Other. a - All. r - Read the file. w - Write or edit the file. x - Execute or run the file as a program. Numeric Permissions: CHMOD can also to attributed by using Numeric Permissions: 400 read by owner 040 read by group 004 read by anybody (other) 200 write by owner 020 write by group 002 write by anybody 100 execute by owner 010 execute by group 001 execute by anybody ls - Short listing of directory contents -a -d -F list hidden files list the name of the current directory show directories with a trailing '/' executable files with a trailing '*' -g -i -l -R -t show group ownership of file in long listing print the inode number of each file long listing giving details about files and directories list all subdirectories encountered sort by time modified instead of name

cp - Copy files cp myfile yourfile

Copy 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 yourfile With 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 destdir Copy all files from the directory "srcdir" to the directory "destdir" preserving links (poption), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another dir ln - Creates a symbolic link to a file. ln -s test symlink Creates 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. locate - A fast database driven file locator. slocate -u This 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 whereis Lists all files whose names contain the string "whereis". directory. more - Allows file contents or piped output to be sent to the screen one page at a time less - Opposite of the more command cat - Sends file contents to standard output. This is a way to list the contents of short files to the screen. Itworks well with piping. whereis - Report all known instances of a command wc - Print byte, word, and line counts bg bg jobs Places the current job (or, by using the alternative form, the specified jobs) in the background, suspending its execution so that a new user prompt appears immediately. Use the jobs command to discover the identities of background jobs. cal month year - Prints a calendar for the specified month of the specified year.

cat files - Prints the contents of the specified files. clear - Clears the terminal screen. cmp file1 file2 - Compares two files, reporting all discrepancies. Similar to the diff command, though the output format differs. diff file1 file2 - Compares two files, reporting all discrepancies. Similar to the cmp command, though the output format differs. dmesg - Prints the messages resulting from the most recent system boot. fg fg jobs - Brings the current job (or the specified jobs) to the foreground. file files - Determines and prints a description of the type of each specified file. find path -name pattern -print Searches the specified path for files with names matching the specified pattern (usually enclosed in single quotes) and prints their names. The find command has many other arguments and functions; see the onlinedocumentation. finger users - Prints descriptions of the specified users. free - Displays the amount of used and free system memory. ftp hostname Opens an FTP connection to the specified host, allowing files to be transferred. The FTP program provides subcommands for accomplishing file transfers; see the online documentation. head files - Prints the first several lines of each specified file. ispell files - Checks the spelling of the contents of the specified files. kill process_ids kill - signal process_ids kill -l Kills the specified processes, sends the specified processes the specified signal (given as a number or name), or prints a list of available signals. killall program killall - signal program Kills all processes that are instances of the specified program or sends the specified signal to all processes that are instances of the specified program. mail - Launches a simple mail client that permits sending and receiving email messages.

man title man section title - Prints the specified man page. ping host - Sends an echo request via TCP/IP to the specified host. A response confirms that the host is operational. reboot - Reboots the system (requires root privileges). shutdown minutes shutdown -r minutes Shuts down the system after the specified number of minutes elapses (requires root privileges). The -r option causes the system to be rebooted once it has shut down. sleep time - Causes the command interpreter to pause for the specified number of seconds. sort files - Sorts the specified files. The command has many useful arguments; see the online documentation. split file - Splits a file into several smaller files. The command has many arguments; see the online documentation sync - Completes all pending input/output operations (requires root privileges). telnet host - Opens a login session on the specified host. top - Prints a display of system processes that's continually updated until the user presses the q key. traceroute host - Uses echo requests to determine and print a network path to the host. uptime - Prints the system uptime. w - Prints the current system users. wall - Prints a message to each user except those who've disabled message reception. Type Ctrl-D to end the message.

Basics Of IP Networking Setting up Hostname Setting up DNS Setting up IP address Setting up Second IP address or Virtual IP address in Debian Setting your default gateway Network testing basics

Networking and IP address tools These tools are really usefull. Ethernet Bonding Configuration in Debian Change your network card MAC Address Basics of IP networking A Debian host may have several interfaces each with a different Internet Protocol (IP) address. Interfaces may be of several different types, including: Loopback: lo Ethernet: eth0, eth1 Wi-Fi: wlan0, wlan1, wifi0, Token Ring: tr0, tr1 PPP: ppp0, ppp1

There is a wide range of other network devices available, including SLIP, PLIP (serial and parallel line IP), "shaper" devices for controlling the traffic on certain interfaces, frame relay, AX.25, X.25, ARCnet, and LocalTalk. Every network interface connected directly to the Internet (or to any IP-based network) is identified by a unique 32 bit IP address. The IP address can be divided into the part that addresses the network and the part that addresses the host. If you take an IP address, set to 1 the bits that are part of the network address and set to 0 the bits that are part of the host address then you get the so-called netmask of the network. Traditionally, IP networks were grouped into classes whose net address parts were 8, 16 or 24 bits in length. This system was inflexible and wasted many IP addresses, so today IPv4 networks are allocated with network address parts of varying length. IP addresses net mask length Class A 1.0.0.0 - 126.255.255.255 255.0.0.0 = /8 Class B 128.0.0.0 - 191.255.255.255 255.255.0.0 = /16 Class C 192.0.0.0 - 223.255.255.255 255.255.255.0 = /24 IP addresses not in these ranges are used for special purposes. There are address ranges in each class reserved for use on local area networks (LANs). These addresses are guaranteed not to conflict with any addresses on the Internet proper. (By the same token, if one of these addresses is assigned to a host then that host must not access the Internet directly but must access it through a gateway that acts as a proxy for individual services or else

does Network Address Translation.) These address ranges are given in the following table along with the number of ranges in each class. network Class A Class B Class C addresses length how many 10.x.x.x /8 1 172.16.x.x - 172.31.x.x /16 16 192.168.0.x - 192.168.255.x /24 256

The first address in an IP network is the address of the network itself. The last address is the broadcast address for the network. All other addresses may be allocated to hosts on the network. Of these, the first or the last address is usually allocated to the Internet gateway for the network. The routing table contains the kernel's information on how to send IP packets to their destinations. Here is a sample routing table printout for a Debian host on a local area network (LAN) with IP address 192.168.50.x/24. Host 192.168.50.1 (also on the LAN) is a router for the corporate network 172.20.x.x/16 and host 192.168.50.254 (also on the LAN) is a router for the Internet at large. # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 127.0.0.0 * 255.0.0.0 U 0 0 2 lo 192.168.50.0 * 255.255.255.0 U 0 0 137 eth0 172.20.0.0 192.168.50.1 255.255.0.0 UG 1 0 7 eth0 default 192.168.50.254 0.0.0.0 UG 1 0 36 eth0 The first line after the heading says that traffic destined for network 127.x.x.x will be routed through lo, the loopback interface. The second line says that traffic destined for hosts on the LAN will be routed through eth0. The third line says that traffic destined for the corporate network will be routed toward gateway192.168.50.1 also through eth0. The fourth line says that traffic destined for the Internet at large will be routed toward gateway192.168.50.254 also through eth0.

IP addresses in the table may also appear as names that are obtained by looking up addresses in/etc/networks or by using the C Library resolver. In addition to routing, the kernel can perform network address translation, traffic shaping and filtering. This article can be found here Setting your hostname Setting up your hostname upon a Debian installation is very straightforward. You can directly query, or set, the hostname with the hostname command. As an user you can see your current hostname with:

$ /bin/hostname Example To set the hostname directly you can become root and run: /bin/hostname newname When your system boots it will automatically read the hostname from the file /etc/hostname Setting up DNS When it comes to DNS setup Debian doesn't differ from other distributions. You can add hostname and IP addresses to the file /etc/hosts for static lokups. To cause your machine to consult with a particular server for name lookups you simply add their addresses to /etc/resolv.conf. For example a machine which should perform lookups from the DNS server at IP address192.168.1.1 would have a resolv.conf file looking like this: search test.com nameserver 192.168.3.2 Setting up IP address. The IP addresses associated with any network cards you might have are read from the file/etc/network/interfaces. A sample entry for a machine with a static address would look something like this: # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.3.90 gateway 192.168.3.1 netmask 255.255.255.0 network 192.168.3.0 broadcast 192.168.3.255 Here we've setup the IP addresss (192.168.3.90), the default gateway (192.168.3.1), and the netmask. For a machine running DHCP the setup would look much simpler: # The loopback network interface auto lo iface lo inet loopback

# The primary network interface - use DHCP to find our address auto eth0 iface eth0 inet dhcp (If you're using a DHCP based setup you must have a DHCP client package installed - usually one of pump,dhcpcd or dhcp3-client.)If you make changes to this file you can cause them to take effect by running: /etc/init.d/networking restart Setting up Second IP address or Virtual IP address in Debian If you are a server system administrator or normal user some time you need to assign a second ipaddress to your debian machine.For this you need to edit the /etc/network/interfaces file and you need to add the following syntax.Below one is the only example you need to chnage according to your ip address settings auto eth0:1 iface eth0:1 inet static address 192.168.1.60 netmask 255.255.255.0 network x.x.x.x broadcast x.x.x.x gateway x.x.x.x You need to enter all the details like address,netmask,network,broadcast and gateways values after entering all the values save this file and you need to restart networking services in debian using the following command to take effect of our new ipaddress. #/etc/init.d/networking restart If you want to check your new ip is assigned or not use the following command #/sbin/ifconfig Setting your default gateway. If you read the previous section then you'll see that the default route for a hos with a static IPaddress can be set in /etc/network/interfaces.If you wish to view your current default route/gateway then you can run: # netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 192.168.3.1 0.0.0.0 UG 0 0 0 eth0

Alternatively you can use the route command: # /sbin/route Kernel IP routing table Destination Gateway Iface 192.168.3.0 * eth0 default router eth0

Genmask 255.255.255.0 0.0.0.0

Flags Metric Ref U UG 0 0 0 0

Use 0 0

(Here the see the hostname router instead of the IP address 192.168.3.1 - to avoid that run "/sbin/route -n"). To change your default route you must first remove the current one: /sbin/route del default gw 192.168.3.1 Once this has done you'll have no gateway and be unable to talk to non-local hosts.Add the new route with : /sbin/route add default gw 192.168.3.100 Network testing basics Install netkit-ping, traceroute, dnsutils, ipchains (for 2.2 kernel), iptables (for 2.4 kernel), and net-toolspackages and: $ ping google.com # check Internet connection $ traceroute google.com # trace IP packets $ ifconfig # check host config $ route -n # check routing config $ dig [@dns-server.com] host.dom [{a|mx|any}] |less # check host.dom DNS records by dns-server.com # for a {a|mx|any} record $ ipchains -L -n |less # check packet filter (2.2 kernel) $ iptables -L -n |less # check packet filter (2.4 kernel) $ netstat -a # find all open ports $ netstat -l --inet # find listening ports $ netstat -ln --tcp # find listening TCP ports (numeric)

Você também pode gostar