Speech:Unix

From Openitware
Jump to: navigation, search


Project Notes


Tips to use this Wiki

To put something in bold, either highlight and click the B in the toolbar above, or just type in three single quotes on either side of your text.

To make a box around something (usually code snippets or commands) simply make sure your line of text is on its own line and hit the space bar right at the beginning of the line so that there is one space before the text begins. When you save it, you'll see a light gray box around your text.

If you want to use Notepad++ and you like to to copy/paste your commands, you might bring along some wiki formatting messing up your commands. Use regular notepad in Windows, which has no formatting in the background that might carry over when you copy/paste commands.

Unix/Linux

GnT32.png Guide to UNIX/Linux color-coding of files and directories.

Remember this when you're having issues with file permissions.


Fwunixrefshot.png Cheat Sheet of Useful Linux Commands

https://www.google.com/search?q=fosswire.com+linux+cheat+sheet&safe=active&rlz=1C1CHZL_enUS703US703&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi1r4q0o_TaAhWso1kKHURuAO4Q_AUICigB&biw=1526&bih=714#imgrc=0fhbvrwTQ-p0vM:

For more specialized needs, see below, personal logs and Google.


Useful Unix Commands

  • To find out which hosts there are, use command cat /etc/hosts
  • To find out what release version you have, use command cat /etc/*-release on the machine you are currently on.

Basic Unix Commands

  • ls or dir will show you the files in the directory you are in.
  • ls -al with show all of the files in directory(even hidden files)
  • cd changes the directory you are in. Example would be cd / which will take you to the root or top directory.
  • pwd is the command that tells you where you are in the hierarchy of the system
  • whoami will tell you what profile you are using
  • man and a command opens the Linux manual pages. Man pages are useful for learning which flags (options) you can use to modify or refine a command.
    • To exit a man page, type q.
  • If you get stuck Ctrl C might work.
  • q to quit
  • ssh and computer name or IP address will secure shell you into the machine.
  • exit will close the session you are on or exit you from a machine you ssh into.
  • top displays information about who is using the machine you are in, CPU % being used and much more

Detailed Unix Commands

Hardware and System

   hwinfo - extended hardware informationar
   hwinfo --short --wlan - hardware info
   hwinfo --short --gfxcard
   lspci - pci information
   ethtool - Ethernet card settings
   free -m - available memory
   ps - process status
   top - list processes and their usage
   who - usernames of whoever is currently logged in
   uname -r - check kernel version
   ls -l /dev/disk/by-id
   df -h - used disk space
   dmidecode -t memory - memory configuration to include type and bank location
    


Networking

   arp - check host network
   netstat - networking info
   netstat | head - summary network information
   netstat -rn - show routes
   nslookup - query name servers
   ping - ICMP request
   ip - configure a network interface
   route - routing information
   ip route - find your gateway
   cat /etc/resolv.conf - find your DNS servers
   ethtool - configure ethernet settings 


File System

   ls -a - lists all files, including hidden files
   ls -t - lists files sorted by date and time 
   ls -l - long listing of files, with files permissions and other info
   ls -alt - long list of all files by date and time << useful to find out when and by whom a file that is causing problems was changed 
   dir - list directory contents
   vdir - verbose directory info
   fdisk -l - list all disk and partitions
   cfdisk - partition table manipulation
   fscheck - file system consistency check and repair <<< only run if you suspect problems with the drives
   format - format disks
   mount
   cat /proc/mounts - lists mounted file systems
   mount caesar:/mnt/main /mnt/main - to mount shared file system from caesar
   wc filename - will display the number of lines, words, and bytes in a file
   tr ' ' '\n' < filename | sort -u | wc -w displays the number of unique words in a file (assuming they are separated by a space)
   tail -f filename - displays output from whatever file is currently being written to ex. tail -f decode.log
   Note: You may want to run the above command in a second terminal window to make sure it doesn't interfere with the current process
         To open a second terminal window, right-click on the toolbar at the top and choose "duplicate session"

SSH Password Override

Using SSH, log in to your account created for you on Caesar. When you log in you should be directed to your home directory.

% sp<semester year>/<user id>

Now that you are at the home directory for your user you want to do the following command to make an SSH key for your user.

ssh-keygen -t rsa

It will prompt the questions below:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/<user id>/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

  • Leave the file name the same.
  • Leave the passphrase empty by simply pressing "Enter".

Now we want to go into the SSH folder:

cd .ssh

You should have the following files in your .ssh folder: id_rsa and id_rsa.pub. To get the key to work so that you do not need a password on the batch machines you need to copy the .pub file to a new file called authorized_keys.

cp -i id_rsa.pub authorized_keys

Since all the machines share the same drive then when you try to SSH into another machine you will not need a password to log into the system.

Troubleshooting

Issue 1:
Fedora not allowing password-less log in.


Possible Solution:

Check if use_nfs_home_dirs parameter is turned on. Fedora comes with SELinux access control and by default the parameter is turned off which prevents a use of NFS home directory.


  • To check if the use_nfs_home_dirs is enabled/disabled use this command
getsebool use_nfs_home_dirs
  • To enable use_nfs_home_dirs use this command
setsebool -P use_nfs_home_dirs 1
  • To disable use_nfs_home_dirs use this command
setsebool -P use_nfs_home_dirs 0